Patchwork [5,of,8] fileset: add function to switch revision where fileset will be evaluated

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


Pierre-Yves David - March 3, 2017, 1:40 p.m.
# HG changeset patch
# User Yuya Nishihara <>
# Date 1422096116 -32400
#      Sat Jan 24 19:41:56 2015 +0900
# Node ID a9e4ff8cb089e0c761c2cf2f87367fd5759306bd
# Parent  70a6ca02bb2d6b41202518bb1d761f7bef785f7e
# EXP-Topic filesetrev-func
# Available At
#              hg pull -r a9e4ff8cb089
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.


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -497,6 +497,9 @@  class matchctx(object):
                 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"""
@@ -504,12 +507,21 @@  class fullmatchctx(matchctx):
     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