Mercurial > public > mercurial-scm > hg
comparison mercurial/hg.py @ 25591:f1d46075b13a
verify: check the subrepository references in .hgsubstate
While hopefully atypical, there are reasons that a subrepository revision can be
lost that aren't covered by corruption of the .hgsubstate revlog. Such things
can happen when a subrepo is amended, stripped or simply isn't pulled from
upstream because the parent repo revision wasn't updated yet. There's no way to
know if it is an error, but this will find potential problems sooner than when
some random revision is updated.
Until recently, convert made no attempt at rewriting the .hgsubstate file. The
impetuous for this is to verify the conversion of some repositories, and this is
orders of magnitude faster than a bash script from 0..tip that does an
'hg update -C $rev'. But it is equally useful to determine if everything has
been pulled down before taking a thumb drive on the go.
It feels somewhat wrong to leave this out of verifymod (mostly because the file
is already read in there, and the final summary is printed before the subrepos
are checked). But verifymod looks very low level, so importing subrepo stuff
there seems more wrong.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 16 Jun 2015 16:15:15 -0400 |
parents | 4cc3fb23881d |
children | f0745da75056 |
comparison
equal
deleted
inserted
replaced
25590:183965a00c76 | 25591:f1d46075b13a |
---|---|
662 """revert changes to revision in node without updating dirstate""" | 662 """revert changes to revision in node without updating dirstate""" |
663 return mergemod.update(repo, node, False, True, choose)[3] > 0 | 663 return mergemod.update(repo, node, False, True, choose)[3] > 0 |
664 | 664 |
665 def verify(repo): | 665 def verify(repo): |
666 """verify the consistency of a repository""" | 666 """verify the consistency of a repository""" |
667 return verifymod.verify(repo) | 667 ret = verifymod.verify(repo) |
668 | |
669 # Broken subrepo references in hidden csets don't seem worth worrying about, | |
670 # since they can't be pushed/pulled, and --hidden can be used if they are a | |
671 # concern. | |
672 | |
673 # pathto() is needed for -R case | |
674 revs = repo.revs("filelog(%s)", | |
675 util.pathto(repo.root, repo.getcwd(), '.hgsubstate')) | |
676 | |
677 if revs: | |
678 repo.ui.status(_('checking subrepo links\n')) | |
679 for rev in revs: | |
680 ctx = repo[rev] | |
681 try: | |
682 for subpath in ctx.substate: | |
683 ret = ctx.sub(subpath).verify() or ret | |
684 except Exception: | |
685 repo.ui.warn(_('.hgsubstate is corrupt in revision %s\n') % | |
686 node.short(ctx.node())) | |
687 | |
688 return ret | |
668 | 689 |
669 def remoteui(src, opts): | 690 def remoteui(src, opts): |
670 'build a remote ui from ui or repo and opts' | 691 'build a remote ui from ui or repo and opts' |
671 if util.safehasattr(src, 'baseui'): # looks like a repository | 692 if util.safehasattr(src, 'baseui'): # looks like a repository |
672 dst = src.baseui.copy() # drop repo-specific config | 693 dst = src.baseui.copy() # drop repo-specific config |