Mercurial > hg-stable
changeset 4378:e33ad7cea15f
Do not automatically rename an atomicfile if a write to it has generated an exception.
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Wed, 25 Apr 2007 13:14:01 -0700 |
parents | 4759da3e4dc8 |
children | 80c7fa620a4d e89f9afc462b |
files | mercurial/util.py |
diffstat | 1 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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: