changeset 18127:dcd43ac7572d

branchmap: simplify write signature All necessary data (cache value and key) are now stored in the branchcache object. Any extra parameter is superfluous.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Sat, 22 Dec 2012 02:04:49 +0100
parents 090ada0acddb
children f0d56efaa35a
files mercurial/branchmap.py mercurial/localrepo.py
diffstat 2 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/branchmap.py	Sat Dec 22 02:06:26 2012 +0100
+++ b/mercurial/branchmap.py	Sat Dec 22 02:04:49 2012 +0100
@@ -42,11 +42,11 @@
         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 @@
         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.
--- a/mercurial/localrepo.py	Sat Dec 22 02:06:26 2012 +0100
+++ b/mercurial/localrepo.py	Sat Dec 22 02:04:49 2012 +0100
@@ -1440,7 +1440,7 @@
             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 @@
                                                   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: