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

login
register
mail settings
Submitter Pierre-Yves David
Date March 6, 2017, 9:36 a.m.
Message ID <54b8e49c33610b648cff.1488793009@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/18918/
State Accepted
Headers show

Comments

Pierre-Yves David - March 6, 2017, 9:36 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.

Patch

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):