Patchwork [1,of,4,PoC,issue4497] fileset: extract function that builds initial subset from ctx or status

login
register
mail settings
Submitter Yuya Nishihara
Date March 24, 2015, 4:36 p.m.
Message ID <ff7b8ab9d021d8cd4dd7.1427215004@mimosa>
Download mbox | patch
Permalink /patch/8233/
State Deferred
Headers show

Comments

Yuya Nishihara - March 24, 2015, 4:36 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1427206249 -32400
#      Tue Mar 24 23:10:49 2015 +0900
# Node ID ff7b8ab9d021d8cd4dd7884b939f4603a092cac8
# Parent  811a1842cfe5f632145912d9bf2dc859e6ee3eeb
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
@@ -490,6 +490,15 @@  def _intree(funcs, tree):
     'symlink',
 ]
 
+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, pos = parse(expr)
     if (pos != len(expr)):
@@ -507,13 +516,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(matchctx(ctx, subset, status), tree)
 
 # tell hggettext to extract docstrings from these functions: