diff mercurial/localrepo.py @ 18126:090ada0acddb

branchmap: add the tiprev (cache key) on the branchmap object The actual cache key used on disk is the (tipnode, tiprev) pair. There is no reason not to use the revision number for the in memory version.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Sat, 22 Dec 2012 02:06:26 +0100
parents ad194a8ab5c1
children dcd43ac7572d
line wrap: on
line diff
--- a/mercurial/localrepo.py	Sat Dec 22 01:59:05 2012 +0100
+++ b/mercurial/localrepo.py	Sat Dec 22 02:06:26 2012 +0100
@@ -1434,13 +1434,13 @@
         # it, Otherwise, since nodes were destroyed, the cache is stale and this
         # will be caught the next time it is read.
         if newheadnodes:
-            tiprev = len(self) - 1
             ctxgen = (self[node] for node in newheadnodes
                       if self.changelog.hasnode(node))
-            branchmap.update(self, self._branchcache, ctxgen)
-            self._branchcache.tipnode = self.changelog.tip()
-            branchmap.write(self, self._branchcache, self._branchcache.tipnode,
-                            tiprev)
+            cache = self._branchcache
+            branchmap.update(self, cache, ctxgen)
+            cache.tipnode = self.changelog.tip()
+            cache.tiprev = self.changelog.rev(cache.tipnode)
+            branchmap.write(self, cache, cache.tipnode, cache.tiprev)
 
         # Ensure the persistent tag cache is updated.  Doing it now
         # means that the tag cache only has to worry about destroyed
@@ -2495,9 +2495,10 @@
                     rtiprev = max((int(self.changelog.rev(node))
                             for node in rbheads))
                     cache = branchmap.branchcache(rbranchmap,
-                                                  self[rtiprev].node())
+                                                  self[rtiprev].node(),
+                                                  rtiprev)
                     self._branchcache = cache
-                    branchmap.write(self, cache, cache.tipnode, rtiprev)
+                    branchmap.write(self, cache, cache.tipnode, cache.tiprev)
             self.invalidate()
             return len(self.heads()) + 1
         finally: