fileset: add class to host special handling of initial subset
authorYuya Nishihara <yuya@tcha.org>
Sat, 24 Jan 2015 19:55:14 +0900
changeset 31188 ec5b56b50e19
parent 31187 6b8e1a08ef1d
child 31189 3c32a3fdfd16
fileset: add class to host special handling of initial subset Future patches will add a function to switch mctx.ctx object so that we can forcibly evaluate a fileset expression in a specified revision. For example, new "revs()" function will be used to match predicate agains another revision $ hg revert 'set:revs(42, added())' fullmatchctx class is similar to revset.fullreposet. It will allow us to recalculate the subset only if it is not filtered yet.
mercurial/fileset.py
--- a/mercurial/fileset.py	Sat Feb 25 18:41:00 2017 +0900
+++ b/mercurial/fileset.py	Sat Jan 24 19:55:14 2015 +0900
@@ -498,6 +498,12 @@
     def narrow(self, files):
         return matchctx(self.ctx, self.filter(files), self._status)
 
+class fullmatchctx(matchctx):
+    """A match context where any files in any revisions should be valid"""
+
+    def __init__(self, ctx, subset=None, status=None):
+        super(fullmatchctx, self).__init__(ctx, subset, status)
+
 def _intree(funcs, tree):
     if isinstance(tree, tuple):
         if tree[0] == 'func' and tree[1][0] == 'symbol':
@@ -529,7 +535,7 @@
         status = None
         subset = list(ctx.walk(ctx.match([])))
 
-    return getset(matchctx(ctx, subset, status), tree)
+    return getset(fullmatchctx(ctx, subset, status), tree)
 
 def prettyformat(tree):
     return parser.prettyformat(tree, ('string', 'symbol'))