localrepo: introduce method for explicit branch cache update
authorGeorg Brandl <georg@python.org>
Sat, 28 Aug 2010 23:57:39 +0200
changeset 12066 d01e28657429
parent 12065 a8b1cb0b0ddb
child 12070 fddacca3202e
localrepo: introduce method for explicit branch cache update Currently, localrepo.branchtags() is called in two locations to update the _branchcache dict, however branchtags() itself does not update anything, it calls branchmap() to do so. This change introduces a new updatebranchcache() method that is used by both branchmap() and the calls to update the cache.
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Fri Aug 27 22:24:47 2010 -0500
+++ b/mercurial/localrepo.py	Sat Aug 28 23:57:39 2010 +0200
@@ -337,8 +337,7 @@
 
         return partial
 
-    def branchmap(self):
-        '''returns a dictionary {branch: [branchheads]}'''
+    def updatebranchcache(self):
         tip = self.changelog.tip()
         if self._branchcache is not None and self._branchcachetip == tip:
             return self._branchcache
@@ -355,6 +354,9 @@
         # this private cache holds all heads (not just tips)
         self._branchcache = partial
 
+    def branchmap(self):
+        '''returns a dictionary {branch: [branchheads]}'''
+        self.updatebranchcache()
         return self._branchcache
 
     def branchtags(self):
@@ -976,7 +978,7 @@
             tr.close()
 
             if self._branchcache:
-                self.branchtags()
+                self.updatebranchcache()
             return n
         finally:
             if tr:
@@ -1700,7 +1702,7 @@
         if changesets > 0:
             # forcefully update the on-disk branch cache
             self.ui.debug("updating the branch cache\n")
-            self.branchtags()
+            self.updatebranchcache()
             self.hook("changegroup", node=hex(cl.node(clstart)),
                       source=srctype, url=url)