Show More
@@ -275,9 +275,9 class basectx(object): | |||
|
275 | 275 | except error.LookupError: |
|
276 | 276 | return '' |
|
277 | 277 | |
|
278 | def sub(self, path): | |
|
278 | def sub(self, path, allowcreate=True): | |
|
279 | 279 | '''return a subrepo for the stored revision of path, never wdir()''' |
|
280 | return subrepo.subrepo(self, path) | |
|
280 | return subrepo.subrepo(self, path, allowcreate=allowcreate) | |
|
281 | 281 | |
|
282 | 282 | def nullsub(self, path, pctx): |
|
283 | 283 | return subrepo.nullsubrepo(self, path, pctx) |
@@ -886,7 +886,11 def verify(repo): | |||
|
886 | 886 | ctx = repo[rev] |
|
887 | 887 | try: |
|
888 | 888 | for subpath in ctx.substate: |
|
889 | ret = ctx.sub(subpath).verify() or ret | |
|
889 | try: | |
|
890 | ret = (ctx.sub(subpath, allowcreate=False).verify() | |
|
891 | or ret) | |
|
892 | except error.RepoError as e: | |
|
893 | repo.ui.warn(_('%s: %s\n') % (rev, e)) | |
|
890 | 894 | except Exception: |
|
891 | 895 | repo.ui.warn(_('.hgsubstate is corrupt in revision %s\n') % |
|
892 | 896 | node.short(ctx.node())) |
@@ -340,7 +340,7 def _sanitize(ui, vfs, ignore): | |||
|
340 | 340 | "in '%s'\n") % vfs.join(dirname)) |
|
341 | 341 | vfs.unlink(vfs.reljoin(dirname, f)) |
|
342 | 342 | |
|
343 | def subrepo(ctx, path, allowwdir=False): | |
|
343 | def subrepo(ctx, path, allowwdir=False, allowcreate=True): | |
|
344 | 344 | """return instance of the right subrepo class for subrepo in path""" |
|
345 | 345 | # subrepo inherently violates our import layering rules |
|
346 | 346 | # because it wants to make repo objects from deep inside the stack |
@@ -356,7 +356,7 def subrepo(ctx, path, allowwdir=False): | |||
|
356 | 356 | raise error.Abort(_('unknown subrepo type %s') % state[2]) |
|
357 | 357 | if allowwdir: |
|
358 | 358 | state = (state[0], ctx.subrev(path), state[2]) |
|
359 | return types[state[2]](ctx, path, state[:2]) | |
|
359 | return types[state[2]](ctx, path, state[:2], allowcreate) | |
|
360 | 360 | |
|
361 | 361 | def nullsubrepo(ctx, path, pctx): |
|
362 | 362 | """return an empty subrepo in pctx for the extant subrepo in ctx""" |
@@ -375,7 +375,7 def nullsubrepo(ctx, path, pctx): | |||
|
375 | 375 | subrev = '' |
|
376 | 376 | if state[2] == 'hg': |
|
377 | 377 | subrev = "0" * 40 |
|
378 | return types[state[2]](pctx, path, (state[0], subrev)) | |
|
378 | return types[state[2]](pctx, path, (state[0], subrev), True) | |
|
379 | 379 | |
|
380 | 380 | def newcommitphase(ui, ctx): |
|
381 | 381 | commitphase = phases.newcommitphase(ui) |
@@ -611,12 +611,12 class abstractsubrepo(object): | |||
|
611 | 611 | return self.wvfs.reljoin(reporelpath(self._ctx.repo()), self._path) |
|
612 | 612 | |
|
613 | 613 | class hgsubrepo(abstractsubrepo): |
|
614 | def __init__(self, ctx, path, state): | |
|
614 | def __init__(self, ctx, path, state, allowcreate): | |
|
615 | 615 | super(hgsubrepo, self).__init__(ctx, path) |
|
616 | 616 | self._state = state |
|
617 | 617 | r = ctx.repo() |
|
618 | 618 | root = r.wjoin(path) |
|
619 | create = not r.wvfs.exists('%s/.hg' % path) | |
|
619 | create = allowcreate and not r.wvfs.exists('%s/.hg' % path) | |
|
620 | 620 | self._repo = hg.repository(r.baseui, root, create=create) |
|
621 | 621 | |
|
622 | 622 | # Propagate the parent's --hidden option |
@@ -1064,7 +1064,7 class hgsubrepo(abstractsubrepo): | |||
|
1064 | 1064 | return reporelpath(self._repo) |
|
1065 | 1065 | |
|
1066 | 1066 | class svnsubrepo(abstractsubrepo): |
|
1067 | def __init__(self, ctx, path, state): | |
|
1067 | def __init__(self, ctx, path, state, allowcreate): | |
|
1068 | 1068 | super(svnsubrepo, self).__init__(ctx, path) |
|
1069 | 1069 | self._state = state |
|
1070 | 1070 | self._exe = util.findexe('svn') |
@@ -1284,7 +1284,7 class svnsubrepo(abstractsubrepo): | |||
|
1284 | 1284 | |
|
1285 | 1285 | |
|
1286 | 1286 | class gitsubrepo(abstractsubrepo): |
|
1287 | def __init__(self, ctx, path, state): | |
|
1287 | def __init__(self, ctx, path, state, allowcreate): | |
|
1288 | 1288 | super(gitsubrepo, self).__init__(ctx, path) |
|
1289 | 1289 | self._state = state |
|
1290 | 1290 | self._abspath = ctx.repo().wjoin(path) |
@@ -121,4 +121,22 verify will warn if locked-in subrepo re | |||
|
121 | 121 | subrepo 'subrepo' is hidden in revision 674d05939c1e |
|
122 | 122 | subrepo 'subrepo' not found in revision a7d05d9055a4 |
|
123 | 123 | |
|
124 | verifying shouldn't init a new subrepo if the reference doesn't exist | |
|
125 | ||
|
126 | $ mv subrepo b | |
|
127 | $ hg verify | |
|
128 | checking changesets | |
|
129 | checking manifests | |
|
130 | crosschecking files in changesets and manifests | |
|
131 | checking files | |
|
132 | 2 files, 5 changesets, 5 total revisions | |
|
133 | checking subrepo links | |
|
134 | 0: repository $TESTTMP/repo/subrepo not found (glob) | |
|
135 | 1: repository $TESTTMP/repo/subrepo not found (glob) | |
|
136 | 3: repository $TESTTMP/repo/subrepo not found (glob) | |
|
137 | 4: repository $TESTTMP/repo/subrepo not found (glob) | |
|
138 | $ ls | |
|
139 | b | |
|
140 | $ mv b subrepo | |
|
141 | ||
|
124 | 142 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now