[PATCH 6 of 7 V4] cache: group obscache and revsfiltercache invalidation in a single function

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Thu Dec 20 10:23:45 CST 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1355792677 -3600
# Node ID f14f34849f9411ba55e7ac0dd953050f09e1f77a
# Parent  454e0d340af6677f9e6c96ed8f83f2cc4b79d49a
cache: group obscache and revsfiltercache invalidation in a single function

Both caches are very volatile and needs invalidation on the same kind of event.
revsfiltercache actually depends on the content of revsfiltercache.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1099,12 +1099,15 @@ class localrepository(object):
             # can't use delattr on proxy
             del self.__dict__['_tagscache']
 
         self.unfiltered()._branchcache = None # in UTF-8
         self.unfiltered()._branchcachetip = None
+        self.invalidatevolatilesets()
+
+    def invalidatevolatilesets(self):
+        self.filteredrevcache.clear()
         obsolete.clearobscaches(self)
-        self.filteredrevcache.clear()
 
     def invalidatedirstate(self):
         '''Invalidates the dirstate, causing the next call to dirstate
         to check if it was modified since the last time it was read,
         rereading it if it has.
@@ -1866,11 +1869,11 @@ class localrepository(object):
                         tr = self.transaction(trname)
                     for key in sorted(remoteobs, reverse=True):
                         if key.startswith('dump'):
                             data = base85.b85decode(remoteobs[key])
                             self.obsstore.mergemarkers(tr, data)
-                    self.filteredrevcache.clear()
+                    self.invalidatevolatilesets()
             if tr is not None:
                 tr.close()
         finally:
             if tr is not None:
                 tr.release()
@@ -2478,12 +2481,11 @@ class localrepository(object):
                 htext = _(" (%+d heads)") % dh
 
             self.ui.status(_("added %d changesets"
                              " with %d changes to %d files%s\n")
                              % (changesets, revisions, files, htext))
-            obsolete.clearobscaches(self)
-            self.filteredrevcache.clear()
+            self.invalidatevolatilesets()
 
             if changesets > 0:
                 p = lambda: cl.writepending() and self.root or ""
                 self.hook('pretxnchangegroup', throw=True,
                           node=hex(cl.node(clstart)), source=srctype,
diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -102,11 +102,10 @@ Note: old client behave as a publishing 
 
 import errno
 from node import nullid, nullrev, bin, hex, short
 from i18n import _
 import util, error
-import obsolete
 
 allphases = public, draft, secret = range(3)
 trackedphases = allphases[1:]
 phasenames = ['public', 'draft', 'secret']
 
@@ -246,12 +245,11 @@ class phasecache(object):
                 # some roots may need to be declared for lower phases
                 delroots.extend(olds - roots)
             # declare deleted root in the target phase
             if targetphase != 0:
                 self.retractboundary(repo, targetphase, delroots)
-        obsolete.clearobscaches(repo)
-        repo.filteredrevcache.clear()
+        repo.invalidatevolatilesets()
 
     def retractboundary(self, repo, targetphase, nodes):
         # Be careful to preserve shallow-copied values: do not update
         # phaseroots values, replace them.
 
@@ -265,12 +263,11 @@ class phasecache(object):
             currentroots = currentroots.copy()
             currentroots.update(newroots)
             ctxs = repo.set('roots(%ln::)', currentroots)
             currentroots.intersection_update(ctx.node() for ctx in ctxs)
             self._updateroots(targetphase, currentroots)
-        obsolete.clearobscaches(repo)
-        repo.filteredrevcache.clear()
+        repo.invalidatevolatilesets()
 
 def advanceboundary(repo, targetphase, nodes):
     """Add nodes to a phase changing other nodes phases if necessary.
 
     This function move boundary *forward* this means that all nodes


More information about the Mercurial-devel mailing list