Patchwork [stable] dirstate: don't rename branch file if writing it failed

login
register
mail settings
Submitter Idan Kamara
Date Dec. 16, 2012, 6:57 p.m.
Message ID <75544dacf843e2e7ba16.1355684231@idan>
Download mbox | patch
Permalink /patch/122/
State Accepted
Commit 3bc21f6daac472b7f4795fa7951f2e4e6458cacb
Headers show

Comments

Idan Kamara - Dec. 16, 2012, 6:57 p.m.
# HG changeset patch
# User Idan Kamara <idankk86 at gmail.com>
# Date 1355595547 -7200
# Branch stable
# Node ID 75544dacf843e2e7ba16de0cc48e7e8d52713494
# Parent  57a75683f8dcfd71f431c08a44461bc543b60690
dirstate: don't rename branch file if writing it failed
Kevin Bullock - Dec. 17, 2012, 4:46 a.m.
On 16 Dec 2012, at 12:57 PM, Idan Kamara wrote:

> # HG changeset patch
> # User Idan Kamara <idankk86 at gmail.com>
> # Date 1355595547 -7200
> # Branch stable
> # Node ID 75544dacf843e2e7ba16de0cc48e7e8d52713494
> # Parent  57a75683f8dcfd71f431c08a44461bc543b60690
> dirstate: don't rename branch file if writing it failed

Looks good, queued.

pacem in terris / ??? / ?????? / ????????? / ??
Kevin R. Bullock

Patch

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -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 = {}