[PATCH 04 of 14 clfilter part 1 V2] clfilter: introduce a `unfilteredmethod` decorator

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Mon Nov 26 12:34:37 CST 2012

# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1353953473 -3600
# Node ID 215b42e05200ff83478dc0badd4742023f0755a4
# Parent  f6833b60312714f2c6828a5ba98f9e3f6f95b4b7
clfilter: introduce a `unfilteredmethod` decorator

This decorator ensure the method in run on an unfiltered version of the
repository. See follow-up commit for details.

This decorator is not named `unfiltered` because it would clash with the
`unfilteredmethod` on `localrepo` itself.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -21,10 +21,16 @@ filecache = scmutil.filecache
 class storecache(filecache):
     """filecache for files in the store"""
     def join(self, obj, fname):
         return obj.sjoin(fname)
+def unfilteredmeth(orig):
+    """decorate method that always need to be run on unfiltered version"""
+    def wrapper(repo, *args, **kwargs):
+        return orig(repo.unfiltered(), *args, **kwargs)
+    return wrapper
 MODERNCAPS = set(('lookup', 'branchmap', 'pushkey', 'known', 'getbundle'))
 LEGACYCAPS = MODERNCAPS.union(set(['changegroupsubset']))
 class localpeer(peer.peerrepository):
     '''peer for a local repo; reflects only the most recent API'''

More information about the Mercurial-devel mailing list