changelog: register changelog.i.a as a temporary file
The file is registered to make sure the transaction is cleaned up in all cases.
--- 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))
--- a/tests/test-hook.t Wed Nov 05 09:27:08 2014 +0000
+++ b/tests/test-hook.t Sat Nov 08 17:08:09 2014 +0000
@@ -148,6 +148,19 @@
$ hg -q tip
4:539e4b31b6dc
+(Check that no 'changelog.i.a' file were left behind)
+
+ $ ls -1 .hg/store/
+ 00changelog.i
+ 00manifest.i
+ data
+ fncache
+ journal.phaseroots
+ phaseroots
+ undo
+ undo.phaseroots
+
+
precommit hook can prevent commit
$ echo "precommit.forbid = python \"$TESTDIR/printenv.py\" precommit.forbid 1" >> .hg/hgrc