diff mercurial/branchmap.py @ 18117:526e7ec5c96e

branchmap: extract write logic from localrepo
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Thu, 20 Dec 2012 13:37:37 +0100
parents bcee63733aad
children e70ff1e599f4
line wrap: on
line diff
--- a/mercurial/branchmap.py	Wed Dec 19 14:43:33 2012 +0100
+++ b/mercurial/branchmap.py	Thu Dec 20 13:37:37 2012 +0100
@@ -4,3 +4,17 @@
 #
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
+
+from node import hex
+import encoding
+
+def write(repo, branches, tip, tiprev):
+    try:
+        f = repo.opener("cache/branchheads", "w", atomictemp=True)
+        f.write("%s %s\n" % (hex(tip), tiprev))
+        for label, nodes in branches.iteritems():
+            for node in nodes:
+                f.write("%s %s\n" % (hex(node), encoding.fromlocal(label)))
+        f.close()
+    except (IOError, OSError):
+        pass