comparison mercurial/subrepo.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 3d8c044ed513
children 70ac1868b707
comparison
equal deleted inserted replaced
25590:183965a00c76 25591:f1d46075b13a
570 return [] 570 return []
571 571
572 def shortid(self, revid): 572 def shortid(self, revid):
573 return revid 573 return revid
574 574
575 def verify(self):
576 '''verify the integrity of the repository. Return 0 on success or
577 warning, 1 on any error.
578 '''
579 return 0
580
575 @propertycache 581 @propertycache
576 def wvfs(self): 582 def wvfs(self):
577 """return vfs to access the working directory of this subrepository 583 """return vfs to access the working directory of this subrepository
578 """ 584 """
579 return scmutil.vfs(self._ctx.repo().wvfs.join(self._path)) 585 return scmutil.vfs(self._ctx.repo().wvfs.join(self._path))
1008 pats = [] 1014 pats = []
1009 cmdutil.revert(self.ui, self._repo, ctx, parents, *pats, **opts) 1015 cmdutil.revert(self.ui, self._repo, ctx, parents, *pats, **opts)
1010 1016
1011 def shortid(self, revid): 1017 def shortid(self, revid):
1012 return revid[:12] 1018 return revid[:12]
1019
1020 def verify(self):
1021 try:
1022 rev = self._state[1]
1023 ctx = self._repo.unfiltered()[rev]
1024 if ctx.hidden():
1025 # Since hidden revisions aren't pushed/pulled, it seems worth an
1026 # explicit warning.
1027 ui = self._repo.ui
1028 ui.warn(_("subrepo '%s' is hidden in revision %s\n") %
1029 (self._relpath, node.short(self._ctx.node())))
1030 return 0
1031 except error.RepoLookupError:
1032 # A missing subrepo revision may be a case of needing to pull it, so
1033 # don't treat this as an error.
1034 self._repo.ui.warn(_("subrepo '%s' not found in revision %s\n") %
1035 (self._relpath, node.short(self._ctx.node())))
1036 return 0
1013 1037
1014 @propertycache 1038 @propertycache
1015 def wvfs(self): 1039 def wvfs(self):
1016 """return own wvfs for efficiency and consitency 1040 """return own wvfs for efficiency and consitency
1017 """ 1041 """