Patchwork [1,of,7] fileset: pass in basectx to _buildstatus()

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 5, 2018, 2:31 p.m.
Message ID <a3523d37efa3421b6593.1533479481@mimosa>
Download mbox | patch
Permalink /patch/33273/
State Accepted
Headers show

Comments

Yuya Nishihara - Aug. 5, 2018, 2:31 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1532224538 -32400
#      Sun Jul 22 10:55:38 2018 +0900
# Node ID a3523d37efa3421b6593a920b25ef1e6680ac990
# Parent  7e75777e4a5136685c2a28de899bac96c31877da
fileset: pass in basectx to _buildstatus()

I'll make matchctx remember both ctx and basectx so that file status between
them can be computed later. This prepares for the change.

Patch

diff --git a/mercurial/fileset.py b/mercurial/fileset.py
--- a/mercurial/fileset.py
+++ b/mercurial/fileset.py
@@ -386,7 +386,8 @@  def revs(mctx, x):
     matchers = []
     for r in revs:
         ctx = repo[r]
-        matchers.append(getmatch(mctx.switch(ctx, _buildstatus(ctx, x)), x))
+        mc = mctx.switch(ctx, _buildstatus(ctx.p1(), ctx, x))
+        matchers.append(getmatch(mc, x))
     if not matchers:
         return mctx.never()
     if len(matchers) == 1:
@@ -413,7 +414,8 @@  def status(mctx, x):
     if not revspec:
         raise error.ParseError(reverr)
     basectx, ctx = scmutil.revpair(repo, [baserevspec, revspec])
-    return getmatch(mctx.switch(ctx, _buildstatus(ctx, x, basectx=basectx)), x)
+    mc = mctx.switch(ctx, _buildstatus(basectx, ctx, x))
+    return getmatch(mc, x)
 
 @predicate('subrepo([pattern])')
 def subrepo(mctx, x):
@@ -538,18 +540,16 @@  def match(ctx, expr, badfn=None):
     tree = filesetlang.parse(expr)
     tree = filesetlang.analyze(tree)
     tree = filesetlang.optimize(tree)
-    mctx = matchctx(ctx, _buildstatus(ctx, tree), badfn=badfn)
+    mctx = matchctx(ctx, _buildstatus(ctx.p1(), ctx, tree), badfn=badfn)
     return getmatch(mctx, tree)
 
-def _buildstatus(ctx, tree, basectx=None):
+def _buildstatus(basectx, ctx, tree):
     # do we need status info?
 
     if _intree(_statuscallers, tree):
         unknown = _intree(['unknown'], tree)
         ignored = _intree(['ignored'], tree)
 
-        if basectx is None:
-            basectx = ctx.p1()
         return basectx.status(ctx, listunknown=unknown, listignored=ignored,
                               listclean=True)
     else: