[PATCH] localrepo: introduce method for explicit branch cache update

Georg Brandl georg at python.org
Sat Aug 28 16:57:42 CDT 2010


# HG changeset patch
# User Georg Brandl <georg at python.org>
# Date 1283032659 -7200
# Node ID a1ac67c821d21f37e456427f2d48bcda8c257334
# Parent  f1d2beebdbc84232d928ce0aab7754dd2c67ccd2
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.

diff -r f1d2beebdbc8 -r a1ac67c821d2 mercurial/localrepo.py
--- a/mercurial/localrepo.py	Sat Aug 28 23:51:01 2010 +0200
+++ 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)
 


More information about the Mercurial-devel mailing list