comparison mercurial/localrepo.py @ 18124:79db6d40bced

branchmap: store branchcache in a dedicated object Value and key of branchcache would benefit from being hold by the same object. Moreover some logic (update, write, validation) could be move on such object. The creation of this object is the first step toward this move. The result will clarify branchcache related code and hide most of the detail in the class itself. This encapsulation will greatly helps implementation of branchcache for filtered view of the repo.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Sat, 22 Dec 2012 01:44:42 +0100
parents 6fb3b8c61775
children ad194a8ab5c1
comparison
equal deleted inserted replaced
18123:6fb3b8c61775 18124:79db6d40bced
664 664
665 def branchmap(self): 665 def branchmap(self):
666 '''returns a dictionary {branch: [branchheads]}''' 666 '''returns a dictionary {branch: [branchheads]}'''
667 if self.changelog.filteredrevs: 667 if self.changelog.filteredrevs:
668 # some changeset are excluded we can't use the cache 668 # some changeset are excluded we can't use the cache
669 bmap = {} 669 bmap = branchmap.branchcache()
670 branchmap.update(self, bmap, (self[r] for r in self)) 670 branchmap.update(self, bmap, (self[r] for r in self))
671 return bmap 671 return bmap
672 else: 672 else:
673 branchmap.updatecache(self) 673 branchmap.updatecache(self)
674 return self._branchcache 674 return self._branchcache
2493 rbheads.extend(bheads) 2493 rbheads.extend(bheads)
2494 2494
2495 if rbheads: 2495 if rbheads:
2496 rtiprev = max((int(self.changelog.rev(node)) 2496 rtiprev = max((int(self.changelog.rev(node))
2497 for node in rbheads)) 2497 for node in rbheads))
2498 self._branchcache = rbranchmap 2498 self._branchcache = branchmap.branchcache(rbranchmap)
2499 rtipnode = self._branchcachetip = self[rtiprev].node() 2499 rtipnode = self._branchcachetip = self[rtiprev].node()
2500 branchmap.write(self, self._branchcache, rtipnode, rtiprev) 2500 branchmap.write(self, self._branchcache, rtipnode, rtiprev)
2501 self.invalidate() 2501 self.invalidate()
2502 return len(self.heads()) + 1 2502 return len(self.heads()) + 1
2503 finally: 2503 finally: