[PATCH 3 of 4] dirstate: write branch file atomically
Idan Kamara
idankk86 at gmail.com
Thu Apr 19 10:31:50 CDT 2012
# HG changeset patch
# User Idan Kamara <idankk86 at gmail.com>
# Date 1334848302 -10800
# Branch stable
# Node ID b849f68987c98411af200f05306a217a30890593
# Parent fc93afd91fcae90e2dd20716f1039b4d54d37191
dirstate: write branch file atomically
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -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 = {}
More information about the Mercurial-devel
mailing list