comparison mercurial/localrepo.py @ 18125:ad194a8ab5c1

branchmap: add the tipnode (cache key) on the branchcache object Gathering data and cache key paves the way to a lot of simplification.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Sat, 22 Dec 2012 01:59:05 +0100
parents 79db6d40bced
children 090ada0acddb
comparison
equal deleted inserted replaced
18124:79db6d40bced 18125:ad194a8ab5c1
227 if create: 227 if create:
228 self._writerequirements() 228 self._writerequirements()
229 229
230 230
231 self._branchcache = None 231 self._branchcache = None
232 self._branchcachetip = None
233 self.filterpats = {} 232 self.filterpats = {}
234 self._datafilters = {} 233 self._datafilters = {}
235 self._transref = self._lockref = self._wlockref = None 234 self._transref = self._lockref = self._wlockref = None
236 235
237 # A cache for various files under .hg/ that tracks file changes, 236 # A cache for various files under .hg/ that tracks file changes,
977 if '_tagscache' in vars(self): 976 if '_tagscache' in vars(self):
978 # can't use delattr on proxy 977 # can't use delattr on proxy
979 del self.__dict__['_tagscache'] 978 del self.__dict__['_tagscache']
980 979
981 self.unfiltered()._branchcache = None # in UTF-8 980 self.unfiltered()._branchcache = None # in UTF-8
982 self.unfiltered()._branchcachetip = None
983 self.invalidatevolatilesets() 981 self.invalidatevolatilesets()
984 982
985 def invalidatevolatilesets(self): 983 def invalidatevolatilesets(self):
986 self.filteredrevcache.clear() 984 self.filteredrevcache.clear()
987 obsolete.clearobscaches(self) 985 obsolete.clearobscaches(self)
1438 if newheadnodes: 1436 if newheadnodes:
1439 tiprev = len(self) - 1 1437 tiprev = len(self) - 1
1440 ctxgen = (self[node] for node in newheadnodes 1438 ctxgen = (self[node] for node in newheadnodes
1441 if self.changelog.hasnode(node)) 1439 if self.changelog.hasnode(node))
1442 branchmap.update(self, self._branchcache, ctxgen) 1440 branchmap.update(self, self._branchcache, ctxgen)
1443 branchmap.write(self, self._branchcache, self.changelog.tip(), 1441 self._branchcache.tipnode = self.changelog.tip()
1442 branchmap.write(self, self._branchcache, self._branchcache.tipnode,
1444 tiprev) 1443 tiprev)
1445 1444
1446 # Ensure the persistent tag cache is updated. Doing it now 1445 # Ensure the persistent tag cache is updated. Doing it now
1447 # means that the tag cache only has to worry about destroyed 1446 # means that the tag cache only has to worry about destroyed
1448 # heads immediately after a strip/rollback. That in turn 1447 # heads immediately after a strip/rollback. That in turn
2493 rbheads.extend(bheads) 2492 rbheads.extend(bheads)
2494 2493
2495 if rbheads: 2494 if rbheads:
2496 rtiprev = max((int(self.changelog.rev(node)) 2495 rtiprev = max((int(self.changelog.rev(node))
2497 for node in rbheads)) 2496 for node in rbheads))
2498 self._branchcache = branchmap.branchcache(rbranchmap) 2497 cache = branchmap.branchcache(rbranchmap,
2499 rtipnode = self._branchcachetip = self[rtiprev].node() 2498 self[rtiprev].node())
2500 branchmap.write(self, self._branchcache, rtipnode, rtiprev) 2499 self._branchcache = cache
2500 branchmap.write(self, cache, cache.tipnode, rtiprev)
2501 self.invalidate() 2501 self.invalidate()
2502 return len(self.heads()) + 1 2502 return len(self.heads()) + 1
2503 finally: 2503 finally:
2504 lock.release() 2504 lock.release()
2505 2505