fileset: extract function that builds initial subset from ctx or status
authorYuya Nishihara <yuya@tcha.org>
Tue, 24 Mar 2015 23:10:49 +0900
changeset 31189 3c32a3fdfd16
parent 31188 ec5b56b50e19
child 31190 2f881e7d1ade
fileset: extract function that builds initial subset from ctx or status This function will be used to recalculate subset when mctx.ctx is switched.
mercurial/fileset.py
--- a/mercurial/fileset.py	Sat Jan 24 19:55:14 2015 +0900
+++ b/mercurial/fileset.py	Tue Mar 24 23:10:49 2015 +0900
@@ -514,6 +514,15 @@
                 return True
     return False
 
+def _buildsubset(ctx, status):
+    if status:
+        subset = []
+        for c in status:
+            subset.extend(c)
+        return subset
+    else:
+        return list(ctx.walk(ctx.match([])))
+
 def getfileset(ctx, expr):
     tree = parse(expr)
 
@@ -528,13 +537,10 @@
         r = ctx.repo()
         status = r.status(ctx.p1(), ctx,
                           unknown=unknown, ignored=ignored, clean=True)
-        subset = []
-        for c in status:
-            subset.extend(c)
     else:
         status = None
-        subset = list(ctx.walk(ctx.match([])))
 
+    subset = _buildsubset(ctx, status)
     return getset(fullmatchctx(ctx, subset, status), tree)
 
 def prettyformat(tree):