[PATCH 3 of 7] fileset: move buildstatus() to matchctx method
Yuya Nishihara
yuya at tcha.org
Sun Aug 5 10:31:23 EDT 2018
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1532225575 -32400
# Sun Jul 22 11:12:55 2018 +0900
# Node ID 8cec7522133a5d5a7b4f6d04fd3a729dcfaac67a
# Parent 733735d06e41efd01c7d21def2a9c00f465ad637
fileset: move buildstatus() to matchctx method
In future patches, file status will be computed while evaluating a parsed
tree. This patch provides a matchctx interface to build status.
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]
- mc = mctx.switch(ctx.p1(), ctx, _buildstatus(ctx.p1(), ctx, x))
+ mc = mctx.switch(ctx.p1(), ctx)
+ mc.buildstatus(x)
matchers.append(getmatch(mc, x))
if not matchers:
return mctx.never()
@@ -414,7 +415,8 @@ def status(mctx, x):
if not revspec:
raise error.ParseError(reverr)
basectx, ctx = scmutil.revpair(repo, [baserevspec, revspec])
- mc = mctx.switch(basectx, ctx, _buildstatus(basectx, ctx, x))
+ mc = mctx.switch(basectx, ctx)
+ mc.buildstatus(x)
return getmatch(mc, x)
@predicate('subrepo([pattern])')
@@ -454,11 +456,21 @@ methods = {
}
class matchctx(object):
- def __init__(self, basectx, ctx, status=None, badfn=None):
+ def __init__(self, basectx, ctx, badfn=None):
self._basectx = basectx
self.ctx = ctx
- self._status = status
self._badfn = badfn
+ self._status = None
+
+ def buildstatus(self, tree):
+ if not _intree(_statuscallers, tree):
+ return
+ unknown = _intree(['unknown'], tree)
+ ignored = _intree(['ignored'], tree)
+ self._status = self._basectx.status(self.ctx,
+ listignored=ignored,
+ listclean=True,
+ listunknown=unknown)
def status(self):
return self._status
@@ -514,8 +526,8 @@ class matchctx(object):
return matchmod.nevermatcher(repo.root, repo.getcwd(),
badfn=self._badfn)
- def switch(self, basectx, ctx, status=None):
- return matchctx(basectx, ctx, status, self._badfn)
+ def switch(self, basectx, ctx):
+ return matchctx(basectx, ctx, self._badfn)
# filesets using matchctx.switch()
_switchcallers = [
@@ -541,21 +553,10 @@ def match(ctx, expr, badfn=None):
tree = filesetlang.parse(expr)
tree = filesetlang.analyze(tree)
tree = filesetlang.optimize(tree)
- mctx = matchctx(ctx.p1(), ctx, _buildstatus(ctx.p1(), ctx, tree),
- badfn=badfn)
+ mctx = matchctx(ctx.p1(), ctx, badfn=badfn)
+ mctx.buildstatus(tree)
return getmatch(mctx, tree)
-def _buildstatus(basectx, ctx, tree):
- # do we need status info?
-
- if _intree(_statuscallers, tree):
- unknown = _intree(['unknown'], tree)
- ignored = _intree(['ignored'], tree)
-
- return basectx.status(ctx, listunknown=unknown, listignored=ignored,
- listclean=True)
- else:
- return None
def loadpredicate(ui, extname, registrarobj):
"""Load fileset predicates from specified registrarobj
More information about the Mercurial-devel
mailing list