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.
--- 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)