Mercurial > hg
comparison mercurial/revlogutils/nodemap.py @ 44319:d58206b70199
nodemap: all check that revision and nodes match in the nodemap
More check is always useful.
Differential Revision: https://phab.mercurial-scm.org/D7846
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 15 Jan 2020 15:49:06 +0100 |
parents | 20e125cdd719 |
children | f0862ee1a31e |
comparison
equal
deleted
inserted
replaced
44318:20e125cdd719 | 44319:d58206b70199 |
---|---|
354 msg = b" revision missing from nodemap: %d\n" % r | 354 msg = b" revision missing from nodemap: %d\n" % r |
355 ui.write_err(msg) | 355 ui.write_err(msg) |
356 ret = 1 | 356 ret = 1 |
357 else: | 357 else: |
358 all_revs.remove(r) | 358 all_revs.remove(r) |
359 nm_rev = _find_node(root, nodemod.hex(index[r][7])) | |
360 if nm_rev is None: | |
361 msg = b" revision node does not match any entries: %d\n" % r | |
362 ui.write_err(msg) | |
363 ret = 1 | |
364 elif nm_rev != r: | |
365 msg = ( | |
366 b" revision node does not match the expected revision: " | |
367 b"%d != %d\n" % (r, nm_rev) | |
368 ) | |
369 ui.write_err(msg) | |
370 ret = 1 | |
371 | |
359 if all_revs: | 372 if all_revs: |
360 for r in sorted(all_revs): | 373 for r in sorted(all_revs): |
361 msg = b" extra revision in nodemap: %d\n" % r | 374 msg = b" extra revision in nodemap: %d\n" % r |
362 ui.write_err(msg) | 375 ui.write_err(msg) |
363 ret = 1 | 376 ret = 1 |
369 for block in _walk_trie(root): | 382 for block in _walk_trie(root): |
370 for v in block: | 383 for v in block: |
371 if v is None or isinstance(v, Block): | 384 if v is None or isinstance(v, Block): |
372 continue | 385 continue |
373 yield v | 386 yield v |
387 | |
388 | |
389 def _find_node(block, node): | |
390 """find the revision associated with a given node""" | |
391 entry = block.get(_to_int(node[0:1])) | |
392 if isinstance(entry, dict): | |
393 return _find_node(entry, node[1:]) | |
394 return entry |