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

login
register
mail settings
Submitter Pierre-Yves David
Date March 6, 2017, 9:36 a.m.
Message ID <a9e4ff8cb089e0c761c2.1488793012@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/18916/
State Accepted
Headers show

Comments

Pierre-Yves David - March 6, 2017, 9:36 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1422096116 -32400
#      Sat Jan 24 19:41:56 2015 +0900
# Node ID a9e4ff8cb089e0c761c2cf2f87367fd5759306bd
# Parent  70a6ca02bb2d6b41202518bb1d761f7bef785f7e
# EXP-Topic filesetrev-func
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -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.

Patch

diff --git a/mercurial/fileset.py b/mercurial/fileset.py
--- a/mercurial/fileset.py
+++ b/mercurial/fileset.py
@@ -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