changeset 18076:3bc21f6daac4 stable

dirstate: don't rename branch file if writing it failed
author Idan Kamara <idankk86@gmail.com>
date Sat, 15 Dec 2012 20:19:07 +0200
parents 7e2b9f6a2cd0
children 777084ac8416
files mercurial/dirstate.py
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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 = {}