Mercurial > hg
changeset 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 | 671f9479af0e |
files | mercurial/revlogutils/nodemap.py |
diffstat | 1 files changed, 21 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revlogutils/nodemap.py Wed Jan 15 15:48:57 2020 +0100 +++ b/mercurial/revlogutils/nodemap.py Wed Jan 15 15:49:06 2020 +0100 @@ -356,6 +356,19 @@ ret = 1 else: all_revs.remove(r) + nm_rev = _find_node(root, nodemod.hex(index[r][7])) + if nm_rev is None: + msg = b" revision node does not match any entries: %d\n" % r + ui.write_err(msg) + ret = 1 + elif nm_rev != r: + msg = ( + b" revision node does not match the expected revision: " + b"%d != %d\n" % (r, nm_rev) + ) + ui.write_err(msg) + ret = 1 + if all_revs: for r in sorted(all_revs): msg = b" extra revision in nodemap: %d\n" % r @@ -371,3 +384,11 @@ if v is None or isinstance(v, Block): continue yield v + + +def _find_node(block, node): + """find the revision associated with a given node""" + entry = block.get(_to_int(node[0:1])) + if isinstance(entry, dict): + return _find_node(entry, node[1:]) + return entry