--- a/tests/test-branches.t Wed Jan 14 01:15:26 2015 +0100
+++ b/tests/test-branches.t Wed Jan 14 01:15:26 2015 +0100
@@ -520,79 +520,104 @@
}
]
-revision branch name caching implementation
+
+Tests of revision branch name caching
+
+We rev branch cache is updated automatically. In these tests we use a trick to
+trigger rebuilds. We remove the branch head cache and run 'hg head' to cause a
+rebuild that also will populate the rev branch cache.
-cache creation
- $ rm .hg/cache/rbc-revs-v1
- $ hg debugrevspec 'branch("re:a ")'
- 7
- $ [ -f .hg/cache/rbc-revs-v1 ] || echo no file
- no file
-recovery from invalid cache file
- $ echo > .hg/cache/rbc-revs-v1
- $ hg debugrevspec 'branch("re:a ")'
- 7
-cache update NOT fully written from revset
- $ "$TESTDIR/md5sum.py" .hg/cache/rbc-revs-v1
- 68b329da9893e34099c7d8ad5cb9c940 .hg/cache/rbc-revs-v1
-recovery from other corruption - extra trailing data
+revision branch cache is created when building the branch head cache
+ $ rm -rf .hg/cache; hg head a -T '{rev}\n'
+ 5
+ $ f --hexdump --size .hg/cache/rbc-*
+ .hg/cache/rbc-names-v1: size=87
+ 0000: 64 65 66 61 75 6c 74 00 61 00 62 00 63 00 61 20 |default.a.b.c.a |
+ 0010: 62 72 61 6e 63 68 20 6e 61 6d 65 20 6d 75 63 68 |branch name much|
+ 0020: 20 6c 6f 6e 67 65 72 20 74 68 61 6e 20 74 68 65 | longer than the|
+ 0030: 20 64 65 66 61 75 6c 74 20 6a 75 73 74 69 66 69 | default justifi|
+ 0040: 63 61 74 69 6f 6e 20 75 73 65 64 20 62 79 20 62 |cation used by b|
+ 0050: 72 61 6e 63 68 65 73 |ranches|
+ .hg/cache/rbc-revs-v1: size=120
+ 0000: 19 70 9c 5a 00 00 00 00 dd 6b 44 0d 00 00 00 01 |.p.Z.....kD.....|
+ 0010: 88 1f e2 b9 00 00 00 01 ac 22 03 33 00 00 00 02 |.........".3....|
+ 0020: ae e3 9c d1 00 00 00 02 d8 cb c6 1d 00 00 00 01 |................|
+ 0030: 58 97 36 a2 00 00 00 03 10 ff 58 95 00 00 00 04 |X.6.......X.....|
+ 0040: ee bb 94 44 00 00 00 02 5f 40 61 bb 00 00 00 02 |...D...._@a.....|
+ 0050: bf be 84 1b 00 00 00 02 d3 f1 63 45 80 00 00 02 |..........cE....|
+ 0060: e3 d4 9c 05 80 00 00 02 e2 3b 55 05 00 00 00 02 |.........;U.....|
+ 0070: f8 94 c2 56 80 00 00 03 |...V....|
+recovery from invalid cache revs file with trailing data
$ echo >> .hg/cache/rbc-revs-v1
- $ hg debugrevspec 'branch("re:a ")'
- 7
-cache update NOT fully written from revset
- $ "$TESTDIR/md5sum.py" .hg/cache/rbc-revs-v1
- e1c06d85ae7b8b032bef47e42e4c08f9 .hg/cache/rbc-revs-v1
-lazy update after commit
- $ hg tag tag
- $ "$TESTDIR/md5sum.py" .hg/cache/rbc-revs-v1
- d0c0166808ee0a1f0e8894915ad363b6 .hg/cache/rbc-revs-v1
- $ hg debugrevspec 'branch("re:a ")'
- 7
- $ "$TESTDIR/md5sum.py" .hg/cache/rbc-revs-v1
- d0c0166808ee0a1f0e8894915ad363b6 .hg/cache/rbc-revs-v1
-update after rollback - cache keeps stripped revs until written for other reasons
+ $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug
+ 5
+ $ f --size .hg/cache/rbc-revs*
+ .hg/cache/rbc-revs-v1: size=120
+recovery from invalid cache file with partial last record
+ $ mv .hg/cache/rbc-revs-v1 .
+ $ f -qDB 119 rbc-revs-v1 > .hg/cache/rbc-revs-v1
+ $ f --size .hg/cache/rbc-revs*
+ .hg/cache/rbc-revs-v1: size=119
+ $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug
+ 5
+ $ f --size .hg/cache/rbc-revs*
+ .hg/cache/rbc-revs-v1: size=120
+recovery from invalid cache file with missing record - no truncation
+ $ mv .hg/cache/rbc-revs-v1 .
+ $ f -qDB 112 rbc-revs-v1 > .hg/cache/rbc-revs-v1
+ $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug
+ 5
+ $ f --size .hg/cache/rbc-revs*
+ .hg/cache/rbc-revs-v1: size=120
+recovery from invalid cache file with some bad records
+ $ mv .hg/cache/rbc-revs-v1 .
+ $ f -qDB 8 rbc-revs-v1 > .hg/cache/rbc-revs-v1
+ $ f --size .hg/cache/rbc-revs*
+ .hg/cache/rbc-revs-v1: size=8
+ $ f -qDB 112 rbc-revs-v1 >> .hg/cache/rbc-revs-v1
+ $ f --size .hg/cache/rbc-revs*
+ .hg/cache/rbc-revs-v1: size=120
+ $ hg log -r 'branch(.)' -T '{rev} '
+ 3 4 8 9 10 11 12 13 (no-eol)
+ $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug
+ 5
+ $ f --size --hexdump --bytes=16 .hg/cache/rbc-revs*
+ .hg/cache/rbc-revs-v1: size=120
+ 0000: 19 70 9c 5a 00 00 00 00 dd 6b 44 0d 00 00 00 01 |.p.Z.....kD.....|
+cache is updated when committing
+ $ hg branch i-will-regret-this
+ marked working directory as branch i-will-regret-this
+ (branches are permanent and global, did you want a bookmark?)
+ $ hg ci -m regrets
+ $ f --size .hg/cache/rbc-*
+ .hg/cache/rbc-names-v1: size=106
+ .hg/cache/rbc-revs-v1: size=128
+update after rollback - the cache will be correct but rbc-names will will still
+contain the branch name even though it no longer is used
$ hg up -qr '.^'
$ hg rollback -qf
- $ "$TESTDIR/md5sum.py" .hg/cache/rbc-revs-v1
- d8c2acdc229bf942fde1dfdbe8f9d933 .hg/cache/rbc-revs-v1
- $ hg debugrevspec 'branch("re:a ")'
- 7
- $ "$TESTDIR/md5sum.py" .hg/cache/rbc-revs-v1
- d8c2acdc229bf942fde1dfdbe8f9d933 .hg/cache/rbc-revs-v1
-handle history mutations that doesn't change the tip node - this is a problem
-with the cache invalidation scheme used by branchmap
- $ hg log -r tip+b -T'{rev}:{node|short} {branch}\n'
- 14:f894c25619d3 c
- 13:e23b5505d1ad b
- $ hg bundle -q --all bu.hg
- $ hg --config extensions.strip= strip --no-b -qr -1:
- $ hg up -q tip
- $ hg branch
- b
- $ hg branch -q hacked
- $ hg ci --amend -qm 'hacked'
- $ hg pull -q bu.hg -r f894c25619d3
- $ hg log -r tip+b -T'{rev}:{node|short} {branch}\n'
- 14:f894c25619d3 c
- 12:e3d49c0575d8 b
- $ hg debugrevspec 'branch("hacked")'
- 13
- $ "$TESTDIR/md5sum.py" .hg/cache/rbc-revs-v1
- 22424d7e106c894336d9d705b0241bc5 .hg/cache/rbc-revs-v1
-cleanup, restore old state
- $ hg --config extensions.strip= strip --no-b -qr -2:
- $ hg pull -q bu.hg
- $ rm bu.hg
- $ hg up -qr tip
- $ hg log -r tip -T'{rev}:{node|short}\n'
- 14:f894c25619d3
-the cache file do not go back to the old state - it still contains the
-now unused 'hacked' branch name)
- $ hg debugrevspec 'branch("re:a ")'
- 7
- $ "$TESTDIR/md5sum.py" .hg/cache/rbc-revs-v1
- d8c2acdc229bf942fde1dfdbe8f9d933 .hg/cache/rbc-revs-v1
- $ cat .hg/cache/rbc-names-v1
- default\x00a\x00b\x00c\x00a branch name much longer than the default justification used by branches\x00hacked (no-eol) (esc)
+ $ f --size --hexdump .hg/cache/rbc-*
+ .hg/cache/rbc-names-v1: size=106
+ 0000: 64 65 66 61 75 6c 74 00 61 00 62 00 63 00 61 20 |default.a.b.c.a |
+ 0010: 62 72 61 6e 63 68 20 6e 61 6d 65 20 6d 75 63 68 |branch name much|
+ 0020: 20 6c 6f 6e 67 65 72 20 74 68 61 6e 20 74 68 65 | longer than the|
+ 0030: 20 64 65 66 61 75 6c 74 20 6a 75 73 74 69 66 69 | default justifi|
+ 0040: 63 61 74 69 6f 6e 20 75 73 65 64 20 62 79 20 62 |cation used by b|
+ 0050: 72 61 6e 63 68 65 73 00 69 2d 77 69 6c 6c 2d 72 |ranches.i-will-r|
+ 0060: 65 67 72 65 74 2d 74 68 69 73 |egret-this|
+ .hg/cache/rbc-revs-v1: size=120
+ 0000: 19 70 9c 5a 00 00 00 00 dd 6b 44 0d 00 00 00 01 |.p.Z.....kD.....|
+ 0010: 88 1f e2 b9 00 00 00 01 ac 22 03 33 00 00 00 02 |.........".3....|
+ 0020: ae e3 9c d1 00 00 00 02 d8 cb c6 1d 00 00 00 01 |................|
+ 0030: 58 97 36 a2 00 00 00 03 10 ff 58 95 00 00 00 04 |X.6.......X.....|
+ 0040: ee bb 94 44 00 00 00 02 5f 40 61 bb 00 00 00 02 |...D...._@a.....|
+ 0050: bf be 84 1b 00 00 00 02 d3 f1 63 45 80 00 00 02 |..........cE....|
+ 0060: e3 d4 9c 05 80 00 00 02 e2 3b 55 05 00 00 00 02 |.........;U.....|
+ 0070: f8 94 c2 56 80 00 00 03 |...V....|
+cache is updated/truncated when stripping - it is thus very hard to get in a
+situation where the cache is out of sync and the hash check detects it
+ $ hg --config extensions.strip= strip -r tip --nob
+ $ f --size .hg/cache/rbc-revs*
+ .hg/cache/rbc-revs-v1: size=112
$ cd ..