changeset 18105:312262ebc223

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.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Tue, 18 Dec 2012 02:04:37 +0100
parents a2cebd3e4daa
children 2cf01eb74842
files mercurial/localrepo.py mercurial/phases.py
diffstat 2 files changed, 8 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Mon Dec 17 17:27:12 2012 +0100
+++ b/mercurial/localrepo.py	Tue Dec 18 02:04:37 2012 +0100
@@ -1101,8 +1101,11 @@
 
         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
@@ -1868,7 +1871,7 @@
                         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:
@@ -2480,8 +2483,7 @@
             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 ""
--- a/mercurial/phases.py	Mon Dec 17 17:27:12 2012 +0100
+++ b/mercurial/phases.py	Tue Dec 18 02:04:37 2012 +0100
@@ -104,7 +104,6 @@
 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:]
@@ -248,8 +247,7 @@
             # 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
@@ -267,8 +265,7 @@
             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.