sapling/eden/hg-server/tests/test-treestate-repack.t
Durham Goode 98d9269874 server: copy hg to a new hg-server directory
Summary:
Create a fork of the Mercurial code that we can use to build server
rpms. The hg servers will continue to exist for a few more months while we move
the darkstorm and ediscovery use cases off them. In the mean time, we want to
start making breaking changes to the client, so let's create a stable copy of
the hg code to produce rpms for the hg servers.

The fork is based off c7770c78d, the latest hg release.

This copies the files as is, then adds some minor tweaks to get it to build:
- Disables some lint checks that appear to be bypassed by path
- sed replace eden/scm with eden/hg-server
- Removed a dependency on scm/telemetry from the edenfs-client tests since
  scm/telemetry pulls in the original eden/scm/lib/configparser which conflicts
  with the hg-server conflict parser.

allow-large-files

Reviewed By: quark-zju

Differential Revision: D27632557

fbshipit-source-id: b2f442f4ec000ea08e4d62de068750832198e1f4
2021-04-09 10:09:06 -07:00

80 lines
2.4 KiB
Perl

#chg-compatible
Fsmonitor makes the size numbers less predicatable.
#require no-fsmonitor
$ setconfig format.dirstate=2
$ setconfig treestate.mingcage=0
Prepare: fake uuid.uuid4 so it becomes predictable
$ cat > fakeuuid.py << EOF
> import os, uuid
> path = os.path.join(os.environ.get('TESTTMP'), 'uuid')
> def uuid4():
> value = 0
> try:
> value = int(open(path).read())
> except Exception:
> pass
> _ = open(path, 'w').write('%s' % (value + 1))
> return '00000000-0000-0000-0000-%012d' % value
> uuid.uuid4 = uuid4
> EOF
$ setconfig extensions.uuid=$TESTTMP/fakeuuid.py debug.dirstate.delaywrite=2
$ setconfig treestate.repackfactor=3 treestate.minrepackthreshold=100
$ umask 022
Make some commits
$ newrepo
$ touch -t 200001010000 a b c d e
$ hg ci -m init -A a b c d e -q --debug 2>&1 | grep treestate
treestate repack threshold set to 507
$ hg debugtreestate
dirstate v2 (using treestate/00000000-0000-0000-0000-000000000000, offset 169, 5 files tracked)
$ echo 1 > a
$ touch -t 200001010000 a
$ hg ci -m modify
$ hg debugtreestate
dirstate v2 (using treestate/00000000-0000-0000-0000-000000000000, offset 300, 5 files tracked)
Repack makes the file smaller
$ hg debugtreestate repack --debug
creating treestate/00000000-0000-0000-0000-000000000001
$ hg debugtreestate
dirstate v2 (using treestate/00000000-0000-0000-0000-000000000001, offset 88, 5 files tracked)
Auto repack happens when treestate exceeds size threshold
$ for i in 12 1 12 1 12 1; do
> echo .
> echo $i > a
> touch -t 200001010000 a
> hg ci -m modify -q --debug 2>&1 | grep treestate
> done
.
treestate repack threshold set to 657
.
.
.
.
.
creating treestate/00000000-0000-0000-0000-000000000002
removing old unreferenced treestate/00000000-0000-0000-0000-000000000000
$ hg debugtreestate
dirstate v2 (using treestate/00000000-0000-0000-0000-000000000002, offset 88, 5 files tracked)
Cleanup removes the leftover files
$ touch .hg/treestate/00000000-0000-0000-0000-000000000005
$ hg debugtreestate cleanup --debug
removing old unreferenced treestate/00000000-0000-0000-0000-000000000005
Cleanup does not remove files that are not old enough
$ touch .hg/treestate/00000000-0000-0000-0000-000000000007
$ hg debugtreestate cleanup --debug --config treestate.mingcage=1000