##// END OF EJS Templates
nodemap: test that an outdated nodemap can catch up...
nodemap: test that an outdated nodemap can catch up If the persistent nodemap does not contains all revision that the index contains, this is should be detected and dealt with. We add a test for this case. Differential Revision: https://phab.mercurial-scm.org/D8183

File last commit:

r44984:1376cb1c default
r44984:1376cb1c default
Show More
test-persistent-nodemap.t
185 lines | 5.7 KiB | text/troff | Tads3Lexer
/ tests / test-persistent-nodemap.t
nodemap: have some python code writing a nodemap in persistent binary form...
r44788 ===================================
Test the persistent on-disk nodemap
===================================
$ hg init test-repo
$ cd test-repo
nodemap: write nodemap data on disk...
r44789 $ cat << EOF >> .hg/hgrc
> [experimental]
> exp-persistent-nodemap=yes
nodemap: add a (python) index class for persistent nodemap testing...
r44794 > [devel]
> persistent-nodemap=yes
nodemap: write nodemap data on disk...
r44789 > EOF
nodemap: have some python code writing a nodemap in persistent binary form...
r44788 $ hg debugbuilddag .+5000
nodemap: add a flag to dump the details of the docket...
r44806 $ hg debugnodemap --metadata
uid: ???????????????? (glob)
nodemap: track the maximum revision tracked in the nodemap...
r44807 tip-rev: 5000
nodemap: track the total and unused amount of data in the rawdata file...
r44808 data-length: 122880
data-unused: 0
nodemap: use an intermediate "docket" file to carry small metadata...
r44792 $ f --size .hg/store/00changelog.n
nodemap: track the total and unused amount of data in the rawdata file...
r44808 .hg/store/00changelog.n: size=42
nodemap: check that a simple lookup works fine...
r44954
Simple lookup works
$ ANYNODE=`hg log --template '{node|short}\n' --rev tip`
$ hg log -r "$ANYNODE" --template '{rev}\n'
5000
nodemap: delete older raw data file when creating a new ones...
r44793 $ f --sha256 .hg/store/00changelog-*.nd
.hg/store/00changelog-????????????????.nd: sha256=b961925120e1c9bc345c199b2cc442abc477029fdece37ef9d99cbe59c0558b7 (glob)
nodemap: add a function to read the data from disk...
r44790 $ hg debugnodemap --dump-new | f --sha256 --size
nodemap: write nodemap data on disk...
r44789 size=122880, sha256=b961925120e1c9bc345c199b2cc442abc477029fdece37ef9d99cbe59c0558b7
nodemap: add a function to read the data from disk...
r44790 $ hg debugnodemap --dump-disk | f --sha256 --bytes=256 --hexdump --size
nodemap: have some python code writing a nodemap in persistent binary form...
r44788 size=122880, sha256=b961925120e1c9bc345c199b2cc442abc477029fdece37ef9d99cbe59c0558b7
0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
0010: ff ff ff ff ff ff ff ff ff ff fa c2 ff ff ff ff |................|
0020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
0030: ff ff ff ff ff ff ed b3 ff ff ff ff ff ff ff ff |................|
0040: ff ff ff ff ff ff ee 34 00 00 00 00 ff ff ff ff |.......4........|
0050: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
0060: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
0070: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
0080: ff ff ff ff ff ff f8 50 ff ff ff ff ff ff ff ff |.......P........|
0090: ff ff ff ff ff ff ff ff ff ff ec c7 ff ff ff ff |................|
00a0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00b0: ff ff ff ff ff ff fa be ff ff f2 fc ff ff ff ff |................|
00c0: ff ff ff ff ff ff ef ea ff ff ff ff ff ff f9 17 |................|
00d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00f0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
nodemap: add basic checking of the on disk nodemap content...
r44799 $ hg debugnodemap --check
revision in index: 5001
revision in nodemap: 5001
nodemap: delete older raw data file when creating a new ones...
r44793
add a new commit
$ hg up
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ echo foo > foo
$ hg add foo
$ hg ci -m 'foo'
nodemap: track the total and unused amount of data in the rawdata file...
r44808
#if pure
nodemap: add a flag to dump the details of the docket...
r44806 $ hg debugnodemap --metadata
uid: ???????????????? (glob)
nodemap: track the maximum revision tracked in the nodemap...
r44807 tip-rev: 5001
nodemap: track the total and unused amount of data in the rawdata file...
r44808 data-length: 123072
data-unused: 192
#else
$ hg debugnodemap --metadata
uid: ???????????????? (glob)
tip-rev: 5001
data-length: 122880
data-unused: 0
#endif
nodemap: delete older raw data file when creating a new ones...
r44793 $ f --size .hg/store/00changelog.n
nodemap: track the total and unused amount of data in the rawdata file...
r44808 .hg/store/00changelog.n: size=42
nodemap: introduce append-only incremental update of the persistent data...
r44805
(The pure code use the debug code that perform incremental update, the C code reencode from scratch)
#if pure
$ f --sha256 .hg/store/00changelog-*.nd --size
.hg/store/00changelog-????????????????.nd: size=123072, sha256=136472751566c8198ff09e306a7d2f9bd18bd32298d614752b73da4d6df23340 (glob)
#else
nodemap: delete older raw data file when creating a new ones...
r44793 $ f --sha256 .hg/store/00changelog-*.nd --size
.hg/store/00changelog-????????????????.nd: size=122880, sha256=bfafebd751c4f6d116a76a37a1dee2a251747affe7efbcc4f4842ccc746d4db9 (glob)
nodemap: introduce append-only incremental update of the persistent data...
r44805
#endif
nodemap: add basic checking of the on disk nodemap content...
r44799 $ hg debugnodemap --check
revision in index: 5002
revision in nodemap: 5002
nodemap: introduce an option to use mmap to read the nodemap mapping...
r44843
Test code path without mmap
---------------------------
$ echo bar > bar
$ hg add bar
$ hg ci -m 'bar' --config experimental.exp-persistent-nodemap.mmap=no
$ hg debugnodemap --check --config experimental.exp-persistent-nodemap.mmap=yes
revision in index: 5003
revision in nodemap: 5003
$ hg debugnodemap --check --config experimental.exp-persistent-nodemap.mmap=no
revision in index: 5003
revision in nodemap: 5003
#if pure
$ hg debugnodemap --metadata
uid: ???????????????? (glob)
tip-rev: 5002
data-length: 123328
data-unused: 384
$ f --sha256 .hg/store/00changelog-*.nd --size
.hg/store/00changelog-????????????????.nd: size=123328, sha256=10d26e9776b6596af0f89143a54eba8cc581e929c38242a02a7b0760698c6c70 (glob)
#else
$ hg debugnodemap --metadata
uid: ???????????????? (glob)
tip-rev: 5002
data-length: 122944
data-unused: 0
$ f --sha256 .hg/store/00changelog-*.nd --size
.hg/store/00changelog-????????????????.nd: size=122944, sha256=755976b22b64ab680401b45395953504e64e7fa8c31ac570f58dee21e15f9bc0 (glob)
#endif
nodemap: warm the persistent nodemap on disk with debugupdatecache...
r44932
Test force warming the cache
$ rm .hg/store/00changelog.n
$ hg debugnodemap --metadata
$ hg debugupdatecache
#if pure
$ hg debugnodemap --metadata
uid: ???????????????? (glob)
tip-rev: 5002
data-length: 122944
data-unused: 0
#else
$ hg debugnodemap --metadata
uid: ???????????????? (glob)
tip-rev: 5002
data-length: 122944
data-unused: 0
#endif
nodemap: test that an outdated nodemap can catch up...
r44984
Check out of sync nodemap
=========================
First copy old data on the side.
$ mkdir ../tmp-copies
$ cp .hg/store/00changelog-????????????????.nd .hg/store/00changelog.n ../tmp-copies
Nodemap lagging behind
----------------------
make a new commit
$ echo bar2 > bar
$ hg ci -m 'bar2'
$ NODE=`hg log -r tip -T '{node}\n'`
$ hg log -r "$NODE" -T '{rev}\n'
5003
If the nodemap is lagging behind, it can catch up fine
$ hg debugnodemap --metadata
uid: ???????????????? (glob)
tip-rev: 5003
data-length: 123200 (pure !)
data-length: 123200 (rust !)
data-length: 122944 (no-rust no-pure !)
data-unused: 256 (pure !)
data-unused: 256 (rust !)
data-unused: 0 (no-rust no-pure !)
$ cp -f ../tmp-copies/* .hg/store/
$ hg debugnodemap --metadata
uid: ???????????????? (glob)
tip-rev: 5002
data-length: 122944
data-unused: 0
$ hg log -r "$NODE" -T '{rev}\n'
5003