Patchwork [3,of,4,PoC,issue4497] fileset: add function to switch revision where fileset will be evaluated

login
register
mail settings
Submitter Yuya Nishihara
Date March 24, 2015, 4:36 p.m.
Message ID <9b86951b17b056847974.1427215006@mimosa>
Download mbox | patch
Permalink /patch/8235/
State Deferred
Headers show

Comments

Yuya Nishihara - March 24, 2015, 4:36 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1422096116 -32400
#      Sat Jan 24 19:41:56 2015 +0900
# Node ID 9b86951b17b05684797489000c1e2df904f2edcc
# Parent  d14fe93f5fbfa9abd86cc0cc0cb97dbffd083c99
fileset: add function to switch revision where fileset will be evaluated

The new subset is narrowed by the existing subset, which means all files in
the new ctx won't appear in set. If we want all files from both old and new
ctxes, we would need a magic similar to revset.fullreposet.

Patch

diff --git a/mercurial/fileset.py b/mercurial/fileset.py
--- a/mercurial/fileset.py
+++ b/mercurial/fileset.py
@@ -470,12 +470,22 @@  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)
+
+# 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