fileset: add function to switch revision where fileset will be evaluated
authorYuya Nishihara <>
Sat, 24 Jan 2015 19:41:56 +0900
changeset 36092 951d95b13487d06636cb21a58f8df0699897691b
parent 36091 3c3ab84e6e783ca45634e5c8b6fe03bc028ed508
child 36093 4140d49d2efb0f73d24fc5bd3614a1b25f1d3270
push id462
push dateThu, 09 Mar 2017 22:10:00 +0000
fileset: add function to switch revision where fileset will be evaluated If the subset isn't filtered yet, i.e. if fullmatchctx, the new subset is recalculated from scratch. Otherwise, it is narrowed by the existing subset.
--- a/mercurial/
+++ b/mercurial/
@@ -492,29 +492,41 @@ class matchctx(object):
             unknown = set(self._status[4] + self._status[5])
             removed = set()
             unknown = set()
         return (f for f in self.subset
                 if (f in self.ctx and f not in removed) or f in unknown)
     def narrow(self, files):
         return matchctx(self.ctx, self.filter(files), self._status)
+    def switch(self, ctx, status=None):
+        subset = self.filter(_buildsubset(ctx, status))
+        return matchctx(ctx, subset, status)
 class fullmatchctx(matchctx):
     """A match context where any files in any revisions should be valid"""
     def __init__(self, ctx, status=None):
         subset = _buildsubset(ctx, status)
         super(fullmatchctx, self).__init__(ctx, subset, status)
+    def switch(self, ctx, status=None):
+        return fullmatchctx(ctx, status)
+# filesets using matchctx.switch()
+_switchcallers = [
 def _intree(funcs, tree):
     if isinstance(tree, tuple):
         if tree[0] == 'func' and tree[1][0] == 'symbol':
             if tree[1][1] in funcs:
                 return True
+            if tree[1][1] in _switchcallers:
+                # arguments won't be evaluated in the current context
+                return False
         for s in tree[1:]:
             if _intree(funcs, s):
                 return True
     return False
 def _buildsubset(ctx, status):
     if status:
         subset = []