branchmap: simplify write signature

All necessary data (cache value and key) are now stored in the branchcache
object. Any extra parameter is superfluous.
This commit is contained in:
Pierre-Yves David 2012-12-22 02:04:49 +01:00
parent 9602b376b6
commit 1bc937448e
2 changed files with 6 additions and 6 deletions

View File

@ -42,11 +42,11 @@ def read(repo):
partial = branchcache()
return partial
def write(repo, branches, tip, tiprev):
def write(repo, cache):
try:
f = repo.opener("cache/branchheads", "w", atomictemp=True)
f.write("%s %s\n" % (hex(tip), tiprev))
for label, nodes in branches.iteritems():
f.write("%s %s\n" % (hex(cache.tipnode), cache.tiprev))
for label, nodes in cache.iteritems():
for node in nodes:
f.write("%s %s\n" % (hex(node), encoding.fromlocal(label)))
f.close()
@ -133,7 +133,7 @@ def updatecache(repo):
update(repo, partial, ctxgen)
partial.tipnode = cl.node(catip)
partial.tiprev = catip
write(repo, partial, partial.tipnode, partial.tiprev)
write(repo, partial)
# If cacheable tip were lower than actual tip, we need to update the
# cache up to tip. This update (from cacheable to actual tip) is not
# written to disk since it's not cacheable.

View File

@ -1440,7 +1440,7 @@ class localrepository(object):
branchmap.update(self, cache, ctxgen)
cache.tipnode = self.changelog.tip()
cache.tiprev = self.changelog.rev(cache.tipnode)
branchmap.write(self, cache, cache.tipnode, cache.tiprev)
branchmap.write(self, cache)
# Ensure the persistent tag cache is updated. Doing it now
# means that the tag cache only has to worry about destroyed
@ -2498,7 +2498,7 @@ class localrepository(object):
self[rtiprev].node(),
rtiprev)
self._branchcache = cache
branchmap.write(self, cache, cache.tipnode, cache.tiprev)
branchmap.write(self, cache)
self.invalidate()
return len(self.heads()) + 1
finally: