Mercurial > hg
comparison mercurial/revlogutils/nodemap.py @ 44318:20e125cdd719
nodemap: add basic checking of the on disk nodemap content
The simplest check it so verify we have all the revision we needs, and nothing
more.
Differential Revision: https://phab.mercurial-scm.org/D7845
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 15 Jan 2020 15:48:57 +0100 |
parents | 78721bbdb2ab |
children | d58206b70199 |
comparison
equal
deleted
inserted
replaced
44317:78721bbdb2ab | 44318:20e125cdd719 |
---|---|
335 elif v >= 0: | 335 elif v >= 0: |
336 b[idx] = block_map[v] | 336 b[idx] = block_map[v] |
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 |