Patchwork [1,of,8] fileset: add class to host special handling of initial subset

mail settings
Submitter Pierre-Yves David
Date March 3, 2017, 1:40 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/18888/
State Superseded
Headers show


Pierre-Yves David - March 3, 2017, 1:40 p.m.
# HG changeset patch
# User Yuya Nishihara <>
# Date 1422096914 -32400
#      Sat Jan 24 19:55:14 2015 +0900
# Node ID cb222708f46971248a687dbdc6a55db11949d9ef
# Parent  3f8f53190d6afed0aca6c6527236edad28ce785c
# EXP-Topic filesetrev-func
# Available At
#              hg pull -r cb222708f469
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.


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -498,6 +498,12 @@  class matchctx(object):
     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 @@  def getfileset(ctx, expr):
         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'))