comparison mercurial/debugcommands.py @ 48089:c87844960a35

dirstate: move verification code within the dirstate itself This move implementation details further down the stack and make it the verification code easier to discover. Differential Revision: https://phab.mercurial-scm.org/D11526
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 30 Sep 2021 12:00:15 +0200
parents cedfe2606adf
children 78e66649cdb3
comparison
equal deleted inserted replaced
48088:418611f18fd8 48089:c87844960a35
548 """validate the correctness of the current dirstate""" 548 """validate the correctness of the current dirstate"""
549 parent1, parent2 = repo.dirstate.parents() 549 parent1, parent2 = repo.dirstate.parents()
550 m1 = repo[parent1].manifest() 550 m1 = repo[parent1].manifest()
551 m2 = repo[parent2].manifest() 551 m2 = repo[parent2].manifest()
552 errors = 0 552 errors = 0
553 for f in repo.dirstate: 553 for err in repo.dirstate.verify(m1, m2):
554 state = repo.dirstate[f] 554 ui.warn(err[0] % err[1:])
555 if state in b"nr" and f not in m1: 555 errors += 1
556 ui.warn(_(b"%s in state %s, but not in manifest1\n") % (f, state))
557 errors += 1
558 if state in b"a" and f in m1:
559 ui.warn(_(b"%s in state %s, but also in manifest1\n") % (f, state))
560 errors += 1
561 if state in b"m" and f not in m1 and f not in m2:
562 ui.warn(
563 _(b"%s in state %s, but not in either manifest\n") % (f, state)
564 )
565 errors += 1
566 for f in m1:
567 state = repo.dirstate[f]
568 if state not in b"nrm":
569 ui.warn(_(b"%s in manifest1, but listed as state %s") % (f, state))
570 errors += 1
571 if errors: 556 if errors:
572 errstr = _(b".hg/dirstate inconsistent with current parent's manifest") 557 errstr = _(b".hg/dirstate inconsistent with current parent's manifest")
573 raise error.Abort(errstr) 558 raise error.Abort(errstr)
574 559
575 560