dirstate: don't rename branch file if writing it failed stable
authorIdan Kamara <idankk86@gmail.com>
Sat, 15 Dec 2012 20:19:07 +0200
branchstable
changeset 18076 3bc21f6daac4
parent 18064 7e2b9f6a2cd0
child 18077 777084ac8416
dirstate: don't rename branch file if writing it failed
mercurial/dirstate.py
--- a/mercurial/dirstate.py	Mon Dec 10 14:58:42 2012 +0100
+++ b/mercurial/dirstate.py	Sat Dec 15 20:19:07 2012 +0200
@@ -265,8 +265,10 @@
         f = self._opener('branch', 'w', atomictemp=True)
         try:
             f.write(self._branch + '\n')
-        finally:
             f.close()
+        except: # re-raises
+            f.discard()
+            raise
 
     def _read(self):
         self._map = {}