Skip to content
Snippets Groups Projects
Commit 24361fb68cba authored by Durham Goode's avatar Durham Goode
Browse files

transaction: abort transaction during hook exception

The new transaction context did not handle the case where an exception during
close should still call release. This cause pretxnclose hooks that failed to
cause the transaction to fail without aborting, thus requiring a hg recover.

I've added a test.
parent f62dea3f3697
No related branches found
No related tags found
No related merge requests found
......@@ -337,9 +337,11 @@
return self
def __exit__(self, exc_type, exc_val, exc_tb):
if exc_type is None:
self.close()
self.release()
try:
if exc_type is None:
self.close()
finally:
self.release()
def running(self):
return self.count > 0
......
......@@ -724,3 +724,25 @@
date: Thu Jan 01 00:00:00 1970 +0000
summary: b
$ cd ..
pretxnclose hook failure should abort the transaction
$ hg init txnfailure
$ cd txnfailure
$ touch a && hg commit -Aqm a
$ cat >> .hg/hgrc <<EOF
> [hooks]
> pretxnclose.error = exit 1
> EOF
$ hg strip -r 0 --config extensions.strip=
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
saved backup bundle to * (glob)
transaction abort!
rollback completed
strip failed, full bundle stored in * (glob)
abort: pretxnclose.error hook exited with status 1
[255]
$ hg recover
no interrupted transaction available
[1]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment