Patchwork [4,of,8] fileset: extract function that builds status tuple only if necessary

login
register
mail settings
Submitter Pierre-Yves David
Date March 3, 2017, 1:40 p.m.
Message ID <70a6ca02bb2d6b412025.1488548441@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/18886/
State Superseded
Headers show

Comments

Pierre-Yves David - March 3, 2017, 1:40 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1422094419 -32400
#      Sat Jan 24 19:13:39 2015 +0900
# Node ID 70a6ca02bb2d6b41202518bb1d761f7bef785f7e
# Parent  dcafd00afeb38478ea65a978b9ada91b4a6ac46b
# 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 70a6ca02bb2d
fileset: extract function that builds status tuple only if necessary

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

Patch

diff --git a/mercurial/fileset.py b/mercurial/fileset.py
--- a/mercurial/fileset.py
+++ b/mercurial/fileset.py
@@ -526,7 +526,9 @@  def _buildsubset(ctx, status):
 
 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
@@ -536,12 +538,10 @@  def getfileset(ctx, expr):
         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'))