[PATCH 2 of 8 V2] fileset: extract function that builds initial subset from ctx or status

Pierre-Yves David pierre-yves.david at ens-lyon.org
Mon Mar 6 04:36:49 EST 2017


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1427206249 -32400
#      Tue Mar 24 23:10:49 2015 +0900
# Node ID 54b8e49c33610b648cff5cbee2c0b306c63a1ebd
# Parent  cb222708f46971248a687dbdc6a55db11949d9ef
# EXP-Topic filesetrev-func
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 54b8e49c3361
fileset: extract function that builds initial subset from ctx or status

This function will be used to recalculate subset when mctx.ctx is switched.

diff --git a/mercurial/fileset.py b/mercurial/fileset.py
--- a/mercurial/fileset.py
+++ b/mercurial/fileset.py
@@ -514,6 +514,15 @@ def _intree(funcs, tree):
                 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 @@ def getfileset(ctx, expr):
         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):


More information about the Mercurial-devel mailing list