Changeset 6b23790bd518…
Parent 29e80a63dfd4…
by
Changes to 2 files · Browse files at 6b23790bd518 Showing diff from parent 29e80a63dfd4 Diff from another changeset...
@@ -27,7 +27,7 @@ except (EnvironmentError, error.LookupError), e:
self.error = hglib.tounicode(str(e))
- def checkMaxDiff(self, ctx, wfile):
+ def checkMaxDiff(self, ctx, wfile, maxdiff=None):
p = _('File or diffs not displayed: ')
try:
fctx = ctx.filectx(wfile)
@@ -41,7 +41,7 @@ except (EnvironmentError, error.LookupError), e:
self.error = p + hglib.tounicode(str(e))
return None
- if size > ctx._repo.maxdiff:
+ if size > maxdiff:
self.error = p + _('File is larger than the specified max size.\n')
return None
try:
@@ -85,7 +85,18 @@ self.flabel += _(' <i>(is a symlink)</i>')
return
- absfile = repo.wjoin(wfile)
+ wsub, wfileinsub, sctx = \
+ hglib.getDeepestSubrepoContainingFile(wfile, ctx)
+ if wsub:
+ topctx = ctx
+ topwfile = wfile
+ ctx = sctx
+ wfile = wfileinsub
+ else:
+ topctx = ctx
+ topwfile = wfile
+
+ absfile = repo.wjoin(os.path.join(wsub or '',wfile))
if (wfile in ctx and 'l' in ctx.flags(wfile)) or \
os.path.islink(absfile):
if wfile in ctx:
@@ -265,7 +276,7 @@ return
if status in ('M', 'A'):
- res = self.checkMaxDiff(ctx, wfile)
+ res = self.checkMaxDiff(ctx, wfile, repo.maxdiff)
if res is None:
return
fctx, newdata = res
|
@@ -559,3 +559,28 @@ except AttributeError:
from mercurial import patch
return patch.export(repo, revs, template, fp, switch_parent, opts)
+
+def getDeepestSubrepoContainingFile(wfile, ctx):
+ """
+ Given a filename and context, get the deepest subrepo that contains the file
+
+ Also return the corresponding subrepo context and the filename relative to
+ its containing subrepo
+ """
+ if wfile in ctx.files():
+ return '', wfile, ctx
+ for wsub in ctx.substate.keys():
+ if wfile.startswith(wsub):
+ srev = ctx.substate[wsub][1]
+ sctx = ctx.sub(wsub)._repo[srev]
+ wfileinsub = wfile[len(wsub)+1:]
+ if wfileinsub in sctx.files():
+ return wsub, wfileinsub, sctx
+ else:
+ wsubsub, wfileinsub, sctx = \
+ getDeepestSubrepoContainingFile(wfileinsub, sctx)
+ if wsubsub is None:
+ return None, wfile, ctx
+ else:
+ return os.path.join(wsub, wsubsub), wfileinsub, sctx
+ return None, wfile, ctx
|
Loading...