Do not automatically rename an atomicfile if a write to it has generated an exception.
authorBrendan Cully <brendan@kublai.com>
Wed, 25 Apr 2007 13:14:01 -0700
changeset 4378 e33ad7cea15f
parent 4377 4759da3e4dc8
child 4379 80c7fa620a4d
child 4380 e89f9afc462b
Do not automatically rename an atomicfile if a write to it has generated an exception.
mercurial/util.py
--- a/mercurial/util.py	Wed Apr 25 18:43:55 2007 +0200
+++ b/mercurial/util.py	Wed Apr 25 13:14:01 2007 -0700
@@ -1161,11 +1161,19 @@
     class atomicfile(atomictempfile):
         """the file will only be copied on close"""
         def __init__(self, name, mode):
+            self._err = False
             atomictempfile.__init__(self, name, mode)
+        def write(self, s):
+            try:
+                atomictempfile.write(self, s)
+            except:
+                self._err = True
+                raise
         def close(self):
             self.rename()
         def __del__(self):
-            self.rename()
+            if not self._err:
+                self.rename()
 
     def o(path, mode="r", text=False, atomic=False, atomictemp=False):
         if audit_p: