diff tests/test-hook.t @ 27924:24361fb68cba stable

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.
author Durham Goode <durham@fb.com>
date Tue, 19 Jan 2016 15:18:21 -0800
parents d6d3cf5fda6f
children 0c9e914029be
line wrap: on
line diff
--- a/tests/test-hook.t	Wed Jan 20 22:39:51 2016 -0600
+++ b/tests/test-hook.t	Tue Jan 19 15:18:21 2016 -0800
@@ -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]