From patchwork Tue Mar 24 16:36:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3, of, 4, PoC, issue4497] fileset: add function to switch revision where fileset will be evaluated From: Yuya Nishihara X-Patchwork-Id: 8235 Message-Id: <9b86951b17b056847974.1427215006@mimosa> To: mercurial-devel@selenic.com Date: Wed, 25 Mar 2015 01:36:46 +0900 # HG changeset patch # User Yuya Nishihara # 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. 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