use atomictemp files to write branch.cache
authorAlexis S. L. Carvalho <alexis@cecm.usp.br>
Mon, 09 Apr 2007 04:24:17 -0300
changeset 4329 cea5ba038a1d
parent 4328 1083ae4b5f0e
child 4330 1b9fc3f48861
use atomictemp files to write branch.cache
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Mon Apr 09 04:24:17 2007 -0300
+++ b/mercurial/localrepo.py	Mon Apr 09 04:24:17 2007 -0300
@@ -421,10 +421,11 @@
 
     def _writebranchcache(self, branches, tip, tiprev):
         try:
-            f = self.opener("branch.cache", "w")
+            f = self.opener("branch.cache", "w", atomictemp=True)
             f.write("%s %s\n" % (hex(tip), tiprev))
             for label, node in branches.iteritems():
                 f.write("%s %s\n" % (hex(node), label))
+            f.rename()
         except IOError:
             pass