changeset 16472:14a4e17f0817 stable

dirstate: write branch file atomically
author Idan Kamara <idankk86@gmail.com>
date Thu, 19 Apr 2012 18:11:42 +0300
parents 85c7602e283a
children 7adc521259d4
files mercurial/dirstate.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dirstate.py	Thu Apr 19 17:59:23 2012 +0300
+++ b/mercurial/dirstate.py	Thu Apr 19 18:11:42 2012 +0300
@@ -244,7 +244,11 @@
         if branch in ['tip', '.', 'null']:
             raise util.Abort(_('the name \'%s\' is reserved') % branch)
         self._branch = encoding.fromlocal(branch)
-        self._opener.write("branch", self._branch + '\n')
+        f = self._opener('branch', 'w', atomictemp=True)
+        try:
+            f.write(self._branch + '\n')
+        finally:
+            f.close()
 
     def _read(self):
         self._map = {}