tests/test-branches.t
changeset 23861 01426cad66dc
parent 23787 678f53865c68
child 23862 7aa1405528a3
equal deleted inserted replaced
23860:bead0c7b4f68 23861:01426cad66dc
   518     "node": "19709c5a4e75bf938f8e349aff97438539bb729e",
   518     "node": "19709c5a4e75bf938f8e349aff97438539bb729e",
   519     "rev": 0
   519     "rev": 0
   520    }
   520    }
   521   ]
   521   ]
   522 
   522 
   523 revision branch name caching implementation
   523 
   524 
   524 Tests of revision branch name caching
   525 cache creation
   525 
   526   $ rm .hg/cache/rbc-revs-v1
   526 We rev branch cache is updated automatically. In these tests we use a trick to
   527   $ hg debugrevspec 'branch("re:a ")'
   527 trigger rebuilds. We remove the branch head cache and run 'hg head' to cause a
   528   7
   528 rebuild that also will populate the rev branch cache.
   529   $ [ -f .hg/cache/rbc-revs-v1 ] || echo no file
   529 
   530   no file
   530 revision branch cache is created when building the branch head cache
   531 recovery from invalid cache file
   531   $ rm -rf .hg/cache; hg head a -T '{rev}\n'
   532   $ echo > .hg/cache/rbc-revs-v1
   532   5
   533   $ hg debugrevspec 'branch("re:a ")'
   533   $ f --hexdump --size .hg/cache/rbc-*
   534   7
   534   .hg/cache/rbc-names-v1: size=87
   535 cache update NOT fully written from revset
   535   0000: 64 65 66 61 75 6c 74 00 61 00 62 00 63 00 61 20 |default.a.b.c.a |
   536   $ "$TESTDIR/md5sum.py" .hg/cache/rbc-revs-v1
   536   0010: 62 72 61 6e 63 68 20 6e 61 6d 65 20 6d 75 63 68 |branch name much|
   537   68b329da9893e34099c7d8ad5cb9c940  .hg/cache/rbc-revs-v1
   537   0020: 20 6c 6f 6e 67 65 72 20 74 68 61 6e 20 74 68 65 | longer than the|
   538 recovery from other corruption - extra trailing data
   538   0030: 20 64 65 66 61 75 6c 74 20 6a 75 73 74 69 66 69 | default justifi|
       
   539   0040: 63 61 74 69 6f 6e 20 75 73 65 64 20 62 79 20 62 |cation used by b|
       
   540   0050: 72 61 6e 63 68 65 73                            |ranches|
       
   541   .hg/cache/rbc-revs-v1: size=120
       
   542   0000: 19 70 9c 5a 00 00 00 00 dd 6b 44 0d 00 00 00 01 |.p.Z.....kD.....|
       
   543   0010: 88 1f e2 b9 00 00 00 01 ac 22 03 33 00 00 00 02 |.........".3....|
       
   544   0020: ae e3 9c d1 00 00 00 02 d8 cb c6 1d 00 00 00 01 |................|
       
   545   0030: 58 97 36 a2 00 00 00 03 10 ff 58 95 00 00 00 04 |X.6.......X.....|
       
   546   0040: ee bb 94 44 00 00 00 02 5f 40 61 bb 00 00 00 02 |...D...._@a.....|
       
   547   0050: bf be 84 1b 00 00 00 02 d3 f1 63 45 80 00 00 02 |..........cE....|
       
   548   0060: e3 d4 9c 05 80 00 00 02 e2 3b 55 05 00 00 00 02 |.........;U.....|
       
   549   0070: f8 94 c2 56 80 00 00 03                         |...V....|
       
   550 recovery from invalid cache revs file with trailing data
   539   $ echo >> .hg/cache/rbc-revs-v1
   551   $ echo >> .hg/cache/rbc-revs-v1
   540   $ hg debugrevspec 'branch("re:a ")'
   552   $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug
   541   7
   553   5
   542 cache update NOT fully written from revset
   554   $ f --size .hg/cache/rbc-revs*
   543   $ "$TESTDIR/md5sum.py" .hg/cache/rbc-revs-v1
   555   .hg/cache/rbc-revs-v1: size=120
   544   e1c06d85ae7b8b032bef47e42e4c08f9  .hg/cache/rbc-revs-v1
   556 recovery from invalid cache file with partial last record
   545 lazy update after commit
   557   $ mv .hg/cache/rbc-revs-v1 .
   546   $ hg tag tag
   558   $ f -qDB 119 rbc-revs-v1 > .hg/cache/rbc-revs-v1
   547   $ "$TESTDIR/md5sum.py" .hg/cache/rbc-revs-v1
   559   $ f --size .hg/cache/rbc-revs*
   548   d0c0166808ee0a1f0e8894915ad363b6  .hg/cache/rbc-revs-v1
   560   .hg/cache/rbc-revs-v1: size=119
   549   $ hg debugrevspec 'branch("re:a ")'
   561   $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug
   550   7
   562   5
   551   $ "$TESTDIR/md5sum.py" .hg/cache/rbc-revs-v1
   563   $ f --size .hg/cache/rbc-revs*
   552   d0c0166808ee0a1f0e8894915ad363b6  .hg/cache/rbc-revs-v1
   564   .hg/cache/rbc-revs-v1: size=120
   553 update after rollback - cache keeps stripped revs until written for other reasons
   565 recovery from invalid cache file with missing record - no truncation
       
   566   $ mv .hg/cache/rbc-revs-v1 .
       
   567   $ f -qDB 112 rbc-revs-v1 > .hg/cache/rbc-revs-v1
       
   568   $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug
       
   569   5
       
   570   $ f --size .hg/cache/rbc-revs*
       
   571   .hg/cache/rbc-revs-v1: size=120
       
   572 recovery from invalid cache file with some bad records
       
   573   $ mv .hg/cache/rbc-revs-v1 .
       
   574   $ f -qDB 8 rbc-revs-v1 > .hg/cache/rbc-revs-v1
       
   575   $ f --size .hg/cache/rbc-revs*
       
   576   .hg/cache/rbc-revs-v1: size=8
       
   577   $ f -qDB 112 rbc-revs-v1 >> .hg/cache/rbc-revs-v1
       
   578   $ f --size .hg/cache/rbc-revs*
       
   579   .hg/cache/rbc-revs-v1: size=120
       
   580   $ hg log -r 'branch(.)' -T '{rev} '
       
   581   3 4 8 9 10 11 12 13  (no-eol)
       
   582   $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug
       
   583   5
       
   584   $ f --size --hexdump --bytes=16 .hg/cache/rbc-revs*
       
   585   .hg/cache/rbc-revs-v1: size=120
       
   586   0000: 19 70 9c 5a 00 00 00 00 dd 6b 44 0d 00 00 00 01 |.p.Z.....kD.....|
       
   587 cache is updated when committing
       
   588   $ hg branch i-will-regret-this
       
   589   marked working directory as branch i-will-regret-this
       
   590   (branches are permanent and global, did you want a bookmark?)
       
   591   $ hg ci -m regrets
       
   592   $ f --size .hg/cache/rbc-*
       
   593   .hg/cache/rbc-names-v1: size=106
       
   594   .hg/cache/rbc-revs-v1: size=128
       
   595 update after rollback - the cache will be correct but rbc-names will will still
       
   596 contain the branch name even though it no longer is used
   554   $ hg up -qr '.^'
   597   $ hg up -qr '.^'
   555   $ hg rollback -qf
   598   $ hg rollback -qf
   556   $ "$TESTDIR/md5sum.py" .hg/cache/rbc-revs-v1
   599   $ f --size --hexdump .hg/cache/rbc-*
   557   d8c2acdc229bf942fde1dfdbe8f9d933  .hg/cache/rbc-revs-v1
   600   .hg/cache/rbc-names-v1: size=106
   558   $ hg debugrevspec 'branch("re:a ")'
   601   0000: 64 65 66 61 75 6c 74 00 61 00 62 00 63 00 61 20 |default.a.b.c.a |
   559   7
   602   0010: 62 72 61 6e 63 68 20 6e 61 6d 65 20 6d 75 63 68 |branch name much|
   560   $ "$TESTDIR/md5sum.py" .hg/cache/rbc-revs-v1
   603   0020: 20 6c 6f 6e 67 65 72 20 74 68 61 6e 20 74 68 65 | longer than the|
   561   d8c2acdc229bf942fde1dfdbe8f9d933  .hg/cache/rbc-revs-v1
   604   0030: 20 64 65 66 61 75 6c 74 20 6a 75 73 74 69 66 69 | default justifi|
   562 handle history mutations that doesn't change the tip node - this is a problem
   605   0040: 63 61 74 69 6f 6e 20 75 73 65 64 20 62 79 20 62 |cation used by b|
   563 with the cache invalidation scheme used by branchmap
   606   0050: 72 61 6e 63 68 65 73 00 69 2d 77 69 6c 6c 2d 72 |ranches.i-will-r|
   564   $ hg log -r tip+b -T'{rev}:{node|short} {branch}\n'
   607   0060: 65 67 72 65 74 2d 74 68 69 73                   |egret-this|
   565   14:f894c25619d3 c
   608   .hg/cache/rbc-revs-v1: size=120
   566   13:e23b5505d1ad b
   609   0000: 19 70 9c 5a 00 00 00 00 dd 6b 44 0d 00 00 00 01 |.p.Z.....kD.....|
   567   $ hg bundle -q --all bu.hg
   610   0010: 88 1f e2 b9 00 00 00 01 ac 22 03 33 00 00 00 02 |.........".3....|
   568   $ hg --config extensions.strip= strip --no-b -qr -1:
   611   0020: ae e3 9c d1 00 00 00 02 d8 cb c6 1d 00 00 00 01 |................|
   569   $ hg up -q tip
   612   0030: 58 97 36 a2 00 00 00 03 10 ff 58 95 00 00 00 04 |X.6.......X.....|
   570   $ hg branch
   613   0040: ee bb 94 44 00 00 00 02 5f 40 61 bb 00 00 00 02 |...D...._@a.....|
   571   b
   614   0050: bf be 84 1b 00 00 00 02 d3 f1 63 45 80 00 00 02 |..........cE....|
   572   $ hg branch -q hacked
   615   0060: e3 d4 9c 05 80 00 00 02 e2 3b 55 05 00 00 00 02 |.........;U.....|
   573   $ hg ci --amend -qm 'hacked'
   616   0070: f8 94 c2 56 80 00 00 03                         |...V....|
   574   $ hg pull -q bu.hg -r f894c25619d3
   617 cache is updated/truncated when stripping - it is thus very hard to get in a
   575   $ hg log -r tip+b -T'{rev}:{node|short} {branch}\n'
   618 situation where the cache is out of sync and the hash check detects it
   576   14:f894c25619d3 c
   619   $ hg --config extensions.strip= strip -r tip --nob
   577   12:e3d49c0575d8 b
   620   $ f --size .hg/cache/rbc-revs*
   578   $ hg debugrevspec 'branch("hacked")'
   621   .hg/cache/rbc-revs-v1: size=112
   579   13
       
   580   $ "$TESTDIR/md5sum.py" .hg/cache/rbc-revs-v1
       
   581   22424d7e106c894336d9d705b0241bc5  .hg/cache/rbc-revs-v1
       
   582 cleanup, restore old state
       
   583   $ hg --config extensions.strip= strip --no-b -qr -2:
       
   584   $ hg pull -q bu.hg
       
   585   $ rm bu.hg
       
   586   $ hg up -qr tip
       
   587   $ hg log -r tip -T'{rev}:{node|short}\n'
       
   588   14:f894c25619d3
       
   589 the cache file do not go back to the old state - it still contains the
       
   590 now unused 'hacked' branch name)
       
   591   $ hg debugrevspec 'branch("re:a ")'
       
   592   7
       
   593   $ "$TESTDIR/md5sum.py" .hg/cache/rbc-revs-v1
       
   594   d8c2acdc229bf942fde1dfdbe8f9d933  .hg/cache/rbc-revs-v1
       
   595   $ cat .hg/cache/rbc-names-v1
       
   596   default\x00a\x00b\x00c\x00a branch name much longer than the default justification used by branches\x00hacked (no-eol) (esc)
       
   597 
   622 
   598   $ cd ..
   623   $ cd ..