comparison mercurial/localrepo.py @ 18126:090ada0acddb

branchmap: add the tiprev (cache key) on the branchmap object The actual cache key used on disk is the (tipnode, tiprev) pair. There is no reason not to use the revision number for the in memory version.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Sat, 22 Dec 2012 02:06:26 +0100
parents ad194a8ab5c1
children dcd43ac7572d
comparison
equal deleted inserted replaced
18125:ad194a8ab5c1 18126:090ada0acddb
1432 ''' 1432 '''
1433 # If we have info, newheadnodes, on how to update the branch cache, do 1433 # If we have info, newheadnodes, on how to update the branch cache, do
1434 # it, Otherwise, since nodes were destroyed, the cache is stale and this 1434 # it, Otherwise, since nodes were destroyed, the cache is stale and this
1435 # will be caught the next time it is read. 1435 # will be caught the next time it is read.
1436 if newheadnodes: 1436 if newheadnodes:
1437 tiprev = len(self) - 1
1438 ctxgen = (self[node] for node in newheadnodes 1437 ctxgen = (self[node] for node in newheadnodes
1439 if self.changelog.hasnode(node)) 1438 if self.changelog.hasnode(node))
1440 branchmap.update(self, self._branchcache, ctxgen) 1439 cache = self._branchcache
1441 self._branchcache.tipnode = self.changelog.tip() 1440 branchmap.update(self, cache, ctxgen)
1442 branchmap.write(self, self._branchcache, self._branchcache.tipnode, 1441 cache.tipnode = self.changelog.tip()
1443 tiprev) 1442 cache.tiprev = self.changelog.rev(cache.tipnode)
1443 branchmap.write(self, cache, cache.tipnode, cache.tiprev)
1444 1444
1445 # Ensure the persistent tag cache is updated. Doing it now 1445 # Ensure the persistent tag cache is updated. Doing it now
1446 # means that the tag cache only has to worry about destroyed 1446 # means that the tag cache only has to worry about destroyed
1447 # heads immediately after a strip/rollback. That in turn 1447 # heads immediately after a strip/rollback. That in turn
1448 # guarantees that "cachetip == currenttip" (comparing both rev 1448 # guarantees that "cachetip == currenttip" (comparing both rev
2493 2493
2494 if rbheads: 2494 if rbheads:
2495 rtiprev = max((int(self.changelog.rev(node)) 2495 rtiprev = max((int(self.changelog.rev(node))
2496 for node in rbheads)) 2496 for node in rbheads))
2497 cache = branchmap.branchcache(rbranchmap, 2497 cache = branchmap.branchcache(rbranchmap,
2498 self[rtiprev].node()) 2498 self[rtiprev].node(),
2499 rtiprev)
2499 self._branchcache = cache 2500 self._branchcache = cache
2500 branchmap.write(self, cache, cache.tipnode, rtiprev) 2501 branchmap.write(self, cache, cache.tipnode, cache.tiprev)
2501 self.invalidate() 2502 self.invalidate()
2502 return len(self.heads()) + 1 2503 return len(self.heads()) + 1
2503 finally: 2504 finally:
2504 lock.release() 2505 lock.release()
2505 2506