fileset: extract function that builds status tuple only if necessary
authorYuya Nishihara <yuya@tcha.org>
Sat, 24 Jan 2015 19:13:39 +0900
changeset 36091 3c3ab84e6e783ca45634e5c8b6fe03bc028ed508
parent 36090 2f881e7d1ade0956f4fde9377d507ee3c6e9451f
child 36092 951d95b13487d06636cb21a58f8df0699897691b
push id462
push usergszorc@mozilla.com
push dateThu, 09 Mar 2017 22:10:00 +0000
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
+++ b/mercurial/fileset.py
@@ -521,32 +521,32 @@ def _buildsubset(ctx, status):
         for c in status:
             subset.extend(c)
         return subset
     else:
         return list(ctx.walk(ctx.match([])))
 
 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
         # for deleted files.
         (ctx.rev() is None and _intree(_existingcallers, tree))):
         unknown = _intree(['unknown'], tree)
         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'))
 
 def loadpredicate(ui, extname, registrarobj):
     """Load fileset predicates from specified registrarobj
     """
     for name, func in registrarobj._table.iteritems():