comparison mercurial/localrepo.py @ 12066:d01e28657429

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.
author Georg Brandl <georg@python.org>
date Sat, 28 Aug 2010 23:57:39 +0200
parents ff1044230bca
children fddacca3202e
comparison
equal deleted inserted replaced
12065:a8b1cb0b0ddb 12066:d01e28657429
335 self._updatebranchcache(partial, ctxgen) 335 self._updatebranchcache(partial, ctxgen)
336 self._writebranchcache(partial, self.changelog.tip(), tiprev) 336 self._writebranchcache(partial, self.changelog.tip(), tiprev)
337 337
338 return partial 338 return partial
339 339
340 def branchmap(self): 340 def updatebranchcache(self):
341 '''returns a dictionary {branch: [branchheads]}'''
342 tip = self.changelog.tip() 341 tip = self.changelog.tip()
343 if self._branchcache is not None and self._branchcachetip == tip: 342 if self._branchcache is not None and self._branchcachetip == tip:
344 return self._branchcache 343 return self._branchcache
345 344
346 oldtip = self._branchcachetip 345 oldtip = self._branchcachetip
353 352
354 self._branchtags(partial, lrev) 353 self._branchtags(partial, lrev)
355 # this private cache holds all heads (not just tips) 354 # this private cache holds all heads (not just tips)
356 self._branchcache = partial 355 self._branchcache = partial
357 356
357 def branchmap(self):
358 '''returns a dictionary {branch: [branchheads]}'''
359 self.updatebranchcache()
358 return self._branchcache 360 return self._branchcache
359 361
360 def branchtags(self): 362 def branchtags(self):
361 '''return a dict where branch names map to the tipmost head of 363 '''return a dict where branch names map to the tipmost head of
362 the branch, open heads come before closed''' 364 the branch, open heads come before closed'''
974 parent2=xp2, pending=p) 976 parent2=xp2, pending=p)
975 self.changelog.finalize(trp) 977 self.changelog.finalize(trp)
976 tr.close() 978 tr.close()
977 979
978 if self._branchcache: 980 if self._branchcache:
979 self.branchtags() 981 self.updatebranchcache()
980 return n 982 return n
981 finally: 983 finally:
982 if tr: 984 if tr:
983 tr.release() 985 tr.release()
984 lock.release() 986 lock.release()
1698 lock.release() 1700 lock.release()
1699 1701
1700 if changesets > 0: 1702 if changesets > 0:
1701 # forcefully update the on-disk branch cache 1703 # forcefully update the on-disk branch cache
1702 self.ui.debug("updating the branch cache\n") 1704 self.ui.debug("updating the branch cache\n")
1703 self.branchtags() 1705 self.updatebranchcache()
1704 self.hook("changegroup", node=hex(cl.node(clstart)), 1706 self.hook("changegroup", node=hex(cl.node(clstart)),
1705 source=srctype, url=url) 1707 source=srctype, url=url)
1706 1708
1707 for i in xrange(clstart, clend): 1709 for i in xrange(clstart, clend):
1708 self.hook("incoming", node=hex(cl.node(i)), 1710 self.hook("incoming", node=hex(cl.node(i)),