Mercurial > public > mercurial-scm > hg-stable
diff mercurial/changelog.py @ 23292:e44399c494ab
changelog: register changelog.i.a as a temporary file
The file is registered to make sure the transaction is cleaned up in all cases.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Sat, 08 Nov 2014 17:08:09 +0000 |
parents | f60ed8cf4afc |
children | 828dc8db5515 |
line wrap: on
line diff
--- a/mercurial/changelog.py Wed Nov 05 09:27:08 2014 +0000 +++ b/mercurial/changelog.py Sat Nov 08 17:08:09 2014 +0000 @@ -273,7 +273,11 @@ if self._delaybuf: # make a temporary copy of the index fp1 = self._realopener(self.indexfile) - fp2 = self._realopener(self.indexfile + ".a", "w") + pendingfilename = self.indexfile + ".a" + # register as a temp file to ensure cleanup on failure + tr.registertmp(pendingfilename) + # write existing data + fp2 = self._realopener(pendingfilename, "w") fp2.write(fp1.read()) # add pending data fp2.write("".join(self._delaybuf))