##// END OF EJS Templates
nodemap: add basic checking of the on disk nodemap content...
marmoute -
r44799:20e125cd default
parent child Browse files
Show More
@@ -2094,6 +2094,12 b' def debugnamecomplete(ui, repo, *args):'
2094 _(b'write a (new) persistent binary nodemap on stdin'),
2094 _(b'write a (new) persistent binary nodemap on stdin'),
2095 ),
2095 ),
2096 (b'', b'dump-disk', False, _(b'dump on-disk data on stdin')),
2096 (b'', b'dump-disk', False, _(b'dump on-disk data on stdin')),
2097 (
2098 b'',
2099 b'check',
2100 False,
2101 _(b'check that the data on disk data are correct.'),
2102 ),
2097 ],
2103 ],
2098 )
2104 )
2099 def debugnodemap(ui, repo, **opts):
2105 def debugnodemap(ui, repo, **opts):
@@ -2109,6 +2115,11 b' def debugnodemap(ui, repo, **opts):'
2109 cl = unfi.changelog
2115 cl = unfi.changelog
2110 data = nodemap.persisted_data(cl)
2116 data = nodemap.persisted_data(cl)
2111 ui.write(data)
2117 ui.write(data)
2118 elif opts['check']:
2119 unfi = repo.unfiltered()
2120 cl = unfi.changelog
2121 data = nodemap.persisted_data(cl)
2122 return nodemap.check_data(ui, cl.index, data)
2112
2123
2113
2124
2114 @command(
2125 @command(
@@ -337,3 +337,37 b' def parse_data(data):'
337 else:
337 else:
338 b[idx] = _transform_rev(v)
338 b[idx] = _transform_rev(v)
339 return block
339 return block
340
341
342 # debug utility
343
344
345 def check_data(ui, index, data):
346 """verify that the provided nodemap data are valid for the given idex"""
347 ret = 0
348 ui.status((b"revision in index: %d\n") % len(index))
349 root = parse_data(data)
350 all_revs = set(_all_revisions(root))
351 ui.status((b"revision in nodemap: %d\n") % len(all_revs))
352 for r in range(len(index)):
353 if r not in all_revs:
354 msg = b" revision missing from nodemap: %d\n" % r
355 ui.write_err(msg)
356 ret = 1
357 else:
358 all_revs.remove(r)
359 if all_revs:
360 for r in sorted(all_revs):
361 msg = b" extra revision in nodemap: %d\n" % r
362 ui.write_err(msg)
363 ret = 1
364 return ret
365
366
367 def _all_revisions(root):
368 """return all revisions stored in a Trie"""
369 for block in _walk_trie(root):
370 for v in block:
371 if v is None or isinstance(v, Block):
372 continue
373 yield v
@@ -291,7 +291,7 b' Show all commands + options'
291 debugmanifestfulltextcache: clear, add
291 debugmanifestfulltextcache: clear, add
292 debugmergestate:
292 debugmergestate:
293 debugnamecomplete:
293 debugnamecomplete:
294 debugnodemap: dump-new, dump-disk
294 debugnodemap: dump-new, dump-disk, check
295 debugobsolete: flags, record-parents, rev, exclusive, index, delete, date, user, template
295 debugobsolete: flags, record-parents, rev, exclusive, index, delete, date, user, template
296 debugp1copies: rev
296 debugp1copies: rev
297 debugp2copies: rev
297 debugp2copies: rev
@@ -36,6 +36,9 b' Test the persistent on-disk nodemap'
36 00d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
36 00d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
37 00e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
37 00e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
38 00f0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
38 00f0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
39 $ hg debugnodemap --check
40 revision in index: 5001
41 revision in nodemap: 5001
39
42
40 add a new commit
43 add a new commit
41
44
@@ -48,3 +51,6 b' add a new commit'
48 .hg/store/00changelog.n: size=18
51 .hg/store/00changelog.n: size=18
49 $ f --sha256 .hg/store/00changelog-*.nd --size
52 $ f --sha256 .hg/store/00changelog-*.nd --size
50 .hg/store/00changelog-????????????????.nd: size=122880, sha256=bfafebd751c4f6d116a76a37a1dee2a251747affe7efbcc4f4842ccc746d4db9 (glob)
53 .hg/store/00changelog-????????????????.nd: size=122880, sha256=bfafebd751c4f6d116a76a37a1dee2a251747affe7efbcc4f4842ccc746d4db9 (glob)
54 $ hg debugnodemap --check
55 revision in index: 5002
56 revision in nodemap: 5002
General Comments 0
You need to be logged in to leave comments. Login now