Comments
Patch
@@ -271,11 +271,15 @@ class changelog(revlog.revlog):
def _writepending(self, tr):
"create a file containing the unfinalized state for pretxnchangegroup"
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))
fp2.close()
# switch modes so finalize can simply rename
@@ -146,10 +146,23 @@ more there after
abort: pretxncommit.forbid1 hook exited with status 1
[255]
$ 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
$ hg commit -m 'fail' -d '4 0'
precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10