Mercurial > public > mercurial-scm > hg-stable
diff mercurial/revlog.py @ 2076:d007df6daf8e
Create an atomic opener that does not automatically rename on close
The revlog.checkinlinesize() uses an atomic opener to replace the
index file after converting it from inline to traditional .i and .d
files. If this operation is interrupted, the atomic file class can
overwrite a valid file with a partially written one.
This patch introduces an atomic opener that does not automatically
replace the destination file with the tempfile. This way
an interrupted checkinlinesize() call turns into a noop.
author | mason@suse.com |
---|---|
date | Tue, 04 Apr 2006 16:38:44 -0400 |
parents | 343aeefb553b |
children | 4d0700ae0991 |
line wrap: on
line diff
--- a/mercurial/revlog.py Tue Apr 04 16:38:43 2006 -0400 +++ b/mercurial/revlog.py Tue Apr 04 16:38:44 2006 -0400 @@ -694,7 +694,7 @@ df.write(d) fp.close() df.close() - fp = self.opener(self.indexfile, 'w', atomic=True) + fp = self.opener(self.indexfile, 'w', atomictemp=True) self.version &= ~(REVLOGNGINLINEDATA) if self.count(): x = self.index[0] @@ -708,7 +708,9 @@ e = struct.pack(self.indexformat, *x) fp.write(e) - fp.close() + # if we don't call rename, the temp file will never replace the + # real index + fp.rename() self.chunkcache = None def addrevision(self, text, transaction, link, p1=None, p2=None, d=None):