[PATCH 06 of 27 clfilter V2] clfilter: decorate several repository methods as unfiltered

Pierre-Yves David pierre-yves.david at ens-lyon.org
Mon Oct 8 16:37:57 CDT 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1349707873 -7200
# Node ID 80cebf327db7794c5ce391c9cfef9041c85e1aaa
# Parent  f572fa1de467af83cc2f11650fe00701bb97151e
clfilter: decorate several repository methods as unfiltered

Some core method of repo need to run on unfiltered version of repository. This
includes:

- logic writing data to the changelog,
- logic computing global cache on the whole set of revision presente in the
  repo.

This changeset introduce an `unfilteredmeth` decorators to decorate
localrepomethod that MUST not be run on the proxied version.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -23,6 +23,11 @@
     def join(self, obj, fname):
         return obj.sjoin(fname)
 
+def unfilteredmeth(orig):
+    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']))
 
@@ -393,6 +398,7 @@
 
     tag_disallowed = ':\r\n'
 
+    @unfilteredmeth
     def _tag(self, names, node, message, local, user, date, extra={}):
         if isinstance(names, str):
             allchars = names
@@ -618,6 +624,7 @@
 
         return partial
 
+    @unfilteredmeth # Until we get a smarter cache management
     def updatebranchcache(self):
         tip = self.changelog.tip()
         if self._branchcache is not None and self._branchcachetip == tip:
@@ -670,6 +677,7 @@
             bt[bn] = self._branchtip(heads)
         return bt
 
+    @unfilteredmeth # Until we get a smarter cache management
     def _readbranchcache(self):
         partial = {}
         try:
@@ -702,6 +710,7 @@
             partial, last, lrev = {}, nullid, nullrev
         return partial, last, lrev
 
+    @unfilteredmeth # Until we get a smarter cache management
     def _writebranchcache(self, branches, tip, tiprev):
         try:
             f = self.opener("cache/branchheads", "w", atomictemp=True)
@@ -713,6 +722,7 @@
         except (IOError, OSError):
             pass
 
+    @unfilteredmeth # Until we get a smarter cache management
     def _updatebranchcache(self, partial, ctxgen):
         """Given a branchhead cache, partial, that may have extra nodes or be
         missing heads, and a generator of nodes that are at least a superset of
@@ -978,6 +988,7 @@
         finally:
             release(lock, wlock)
 
+    @unfilteredmeth # Until we get a smarter cache management
     def _rollback(self, dryrun, force):
         ui = self.ui
         try:
@@ -1056,8 +1067,8 @@
 
         delcache('_tagscache')
 
-        self._branchcache = None # in UTF-8
-        self._branchcachetip = None
+        self.unfiltered()._branchcache = None # in UTF-8
+        self.unfiltered()._branchcachetip = None
         obsolete.clearobscaches(self)
 
     def invalidatedirstate(self):
@@ -1075,16 +1086,17 @@
                     delattr(self.dirstate, k)
                 except AttributeError:
                     pass
-            delattr(self, 'dirstate')
+            delattr(self.unfiltered(), 'dirstate')
 
     def invalidate(self):
+        unfiltered = self.unfiltered() # all filecache are store on unfiltered
         for k in self._filecache:
             # dirstate is invalidated separately in invalidatedirstate()
             if k == 'dirstate':
                 continue
-
             try:
-                delattr(self, k)
+                #
+                delattr(unfiltered, k)
             except AttributeError:
                 pass
         self.invalidatecaches()
@@ -1238,6 +1250,7 @@
 
         return fparent1
 
+    @unfilteredmeth
     def commit(self, text="", user=None, date=None, match=None, force=False,
                editor=False, extra={}):
         """Add a new revision to current repository.
@@ -1408,6 +1421,7 @@
         self._afterlock(commithook)
         return ret
 
+    @unfilteredmeth
     def commitctx(self, ctx, error=False):
         """Add a new revision to current repository.
         Revision information is passed via the context argument.
@@ -1489,6 +1503,7 @@
                 tr.release()
             lock.release()
 
+    @unfilteredmeth
     def destroyed(self, newheadnodes=None):
         '''Inform the repository that nodes have been destroyed.
         Intended for use by strip and rollback, so there's a common
@@ -2079,6 +2094,7 @@
         return self.getlocalbundle(source,
                                    discovery.outgoing(cl, common, heads))
 
+    @unfilteredmeth
     def _changegroupsubset(self, commonrevs, csets, heads, source):
 
         cl = self.changelog
@@ -2190,6 +2206,7 @@
         # to avoid a race we use changegroupsubset() (issue1320)
         return self.changegroupsubset(basenodes, self.heads(), source)
 
+    @unfilteredmeth
     def _changegroup(self, nodes, source):
         """Compute the changegroup of all nodes that we have that a recipient
         doesn't.  Return a chunkbuffer object whose read() method will return
@@ -2283,6 +2300,7 @@
 
         return changegroup.unbundle10(util.chunkbuffer(gengroup()), 'UN')
 
+    @unfilteredmeth
     def addchangegroup(self, source, srctype, url, emptyok=False):
         """Add the changegroup returned by source.read() to this repo.
         srctype is a string like 'push', 'pull', or 'unbundle'.  url is


More information about the Mercurial-devel mailing list