fileset: extract function that builds status tuple only if necessary
authorYuya Nishihara <yuya@tcha.org>
Sat, 24 Jan 2015 19:13:39 +0900
changeset 31191 3c3ab84e6e78
parent 31190 2f881e7d1ade
child 31192 951d95b13487
fileset: extract function that builds status tuple only if necessary This function will be used to recalculate status when mctx.ctx is switched.
mercurial/fileset.py
--- a/mercurial/fileset.py	Sat Jan 24 18:56:02 2015 +0900
+++ b/mercurial/fileset.py	Sat Jan 24 19:13:39 2015 +0900
@@ -526,7 +526,9 @@
 
 def getfileset(ctx, expr):
     tree = parse(expr)
+    return getset(fullmatchctx(ctx, _buildstatus(ctx, tree)), tree)
 
+def _buildstatus(ctx, tree):
     # do we need status info?
     if (_intree(_statuscallers, tree) or
         # Using matchctx.existing() on a workingctx requires us to check
@@ -536,12 +538,10 @@
         ignored = _intree(['ignored'], tree)
 
         r = ctx.repo()
-        status = r.status(ctx.p1(), ctx,
-                          unknown=unknown, ignored=ignored, clean=True)
+        return r.status(ctx.p1(), ctx,
+                        unknown=unknown, ignored=ignored, clean=True)
     else:
-        status = None
-
-    return getset(fullmatchctx(ctx, status), tree)
+        return None
 
 def prettyformat(tree):
     return parser.prettyformat(tree, ('string', 'symbol'))