@@ -275,9 +275,9 @@
except error.LookupError:
return ''
- def sub(self, path):
+ def sub(self, path, allowcreate=True):
'''return a subrepo for the stored revision of path, never wdir()'''
- return subrepo.subrepo(self, path)
+ return subrepo.subrepo(self, path, allowcreate=allowcreate)
def nullsub(self, path, pctx):
return subrepo.nullsubrepo(self, path, pctx)
@@ -828,7 +828,7 @@
ctx = repo[rev]
try:
for subpath in ctx.substate:
- ret = ctx.sub(subpath).verify() or ret
+ ret = ctx.sub(subpath, allowcreate=False).verify() or ret
except Exception:
repo.ui.warn(_('.hgsubstate is corrupt in revision %s\n') %
node.short(ctx.node()))
@@ -340,7 +340,7 @@
"in '%s'\n") % vfs.join(dirname))
vfs.unlink(vfs.reljoin(dirname, f))
-def subrepo(ctx, path, allowwdir=False):
+def subrepo(ctx, path, allowwdir=False, allowcreate=True):
"""return instance of the right subrepo class for subrepo in path"""
# subrepo inherently violates our import layering rules
# because it wants to make repo objects from deep inside the stack
@@ -356,7 +356,7 @@
raise error.Abort(_('unknown subrepo type %s') % state[2])
if allowwdir:
state = (state[0], ctx.subrev(path), state[2])
- return types[state[2]](ctx, path, state[:2])
+ return types[state[2]](ctx, path, state[:2], allowcreate)
def nullsubrepo(ctx, path, pctx):
"""return an empty subrepo in pctx for the extant subrepo in ctx"""
@@ -375,7 +375,7 @@
subrev = ''
if state[2] == 'hg':
subrev = "0" * 40
- return types[state[2]](pctx, path, (state[0], subrev))
+ return types[state[2]](pctx, path, (state[0], subrev), True)
def newcommitphase(ui, ctx):
commitphase = phases.newcommitphase(ui)
@@ -609,12 +609,12 @@
return self.wvfs.reljoin(reporelpath(self._ctx.repo()), self._path)
class hgsubrepo(abstractsubrepo):
- def __init__(self, ctx, path, state):
+ def __init__(self, ctx, path, state, allowcreate):
super(hgsubrepo, self).__init__(ctx, path)
self._state = state
r = ctx.repo()
root = r.wjoin(path)
- create = not r.wvfs.exists('%s/.hg' % path)
+ create = allowcreate and not r.wvfs.exists('%s/.hg' % path)
self._repo = hg.repository(r.baseui, root, create=create)
# Propagate the parent's --hidden option
@@ -1062,7 +1062,7 @@
return reporelpath(self._repo)
class svnsubrepo(abstractsubrepo):
- def __init__(self, ctx, path, state):
+ def __init__(self, ctx, path, state, allowcreate):
super(svnsubrepo, self).__init__(ctx, path)
self._state = state
self._exe = util.findexe('svn')
@@ -1282,7 +1282,7 @@
class gitsubrepo(abstractsubrepo):
- def __init__(self, ctx, path, state):
+ def __init__(self, ctx, path, state, allowcreate):
super(gitsubrepo, self).__init__(ctx, path)
self._state = state
self._abspath = ctx.repo().wjoin(path)
@@ -121,4 +121,23 @@
subrepo 'subrepo' is hidden in revision 674d05939c1e
subrepo 'subrepo' not found in revision a7d05d9055a4
+verifying shouldn't init a new subrepo if the reference doesn't exist
+
+ $ mv subrepo b
+ $ hg verify
+ checking changesets
+ checking manifests
+ crosschecking files in changesets and manifests
+ checking files
+ 2 files, 5 changesets, 5 total revisions
+ checking subrepo links
+ .hgsubstate is corrupt in revision ef278ff32036
+ .hgsubstate is corrupt in revision a66de08943b6
+ .hgsubstate is corrupt in revision 674d05939c1e
+ .hgsubstate is corrupt in revision a7d05d9055a4
+ $ find subrepo
+ find: `subrepo': * (glob)
+ [1]
+ $ mv b subrepo
+
$ cd ..