Mercurial > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
23291:03d2d6931836 | 23292:e44399c494ab |
---|---|
271 def _writepending(self, tr): | 271 def _writepending(self, tr): |
272 "create a file containing the unfinalized state for pretxnchangegroup" | 272 "create a file containing the unfinalized state for pretxnchangegroup" |
273 if self._delaybuf: | 273 if self._delaybuf: |
274 # make a temporary copy of the index | 274 # make a temporary copy of the index |
275 fp1 = self._realopener(self.indexfile) | 275 fp1 = self._realopener(self.indexfile) |
276 fp2 = self._realopener(self.indexfile + ".a", "w") | 276 pendingfilename = self.indexfile + ".a" |
277 # register as a temp file to ensure cleanup on failure | |
278 tr.registertmp(pendingfilename) | |
279 # write existing data | |
280 fp2 = self._realopener(pendingfilename, "w") | |
277 fp2.write(fp1.read()) | 281 fp2.write(fp1.read()) |
278 # add pending data | 282 # add pending data |
279 fp2.write("".join(self._delaybuf)) | 283 fp2.write("".join(self._delaybuf)) |
280 fp2.close() | 284 fp2.close() |
281 # switch modes so finalize can simply rename | 285 # switch modes so finalize can simply rename |