diff mercurial/localrepo.py @ 18125:ad194a8ab5c1

branchmap: add the tipnode (cache key) on the branchcache object Gathering data and cache key paves the way to a lot of simplification.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Sat, 22 Dec 2012 01:59:05 +0100
parents 79db6d40bced
children 090ada0acddb
line wrap: on
line diff
--- a/mercurial/localrepo.py	Sat Dec 22 01:44:42 2012 +0100
+++ b/mercurial/localrepo.py	Sat Dec 22 01:59:05 2012 +0100
@@ -229,7 +229,6 @@
 
 
         self._branchcache = None
-        self._branchcachetip = None
         self.filterpats = {}
         self._datafilters = {}
         self._transref = self._lockref = self._wlockref = None
@@ -979,7 +978,6 @@
             del self.__dict__['_tagscache']
 
         self.unfiltered()._branchcache = None # in UTF-8
-        self.unfiltered()._branchcachetip = None
         self.invalidatevolatilesets()
 
     def invalidatevolatilesets(self):
@@ -1440,7 +1438,8 @@
             ctxgen = (self[node] for node in newheadnodes
                       if self.changelog.hasnode(node))
             branchmap.update(self, self._branchcache, ctxgen)
-            branchmap.write(self, self._branchcache, self.changelog.tip(),
+            self._branchcache.tipnode = self.changelog.tip()
+            branchmap.write(self, self._branchcache, self._branchcache.tipnode,
                             tiprev)
 
         # Ensure the persistent tag cache is updated.  Doing it now
@@ -2495,9 +2494,10 @@
                 if rbheads:
                     rtiprev = max((int(self.changelog.rev(node))
                             for node in rbheads))
-                    self._branchcache = branchmap.branchcache(rbranchmap)
-                    rtipnode = self._branchcachetip = self[rtiprev].node()
-                    branchmap.write(self, self._branchcache, rtipnode, rtiprev)
+                    cache = branchmap.branchcache(rbranchmap,
+                                                  self[rtiprev].node())
+                    self._branchcache = cache
+                    branchmap.write(self, cache, cache.tipnode, rtiprev)
             self.invalidate()
             return len(self.heads()) + 1
         finally: