transaction: run abort callback in all cases
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 14 Feb 2023 20:04:17 +0100
changeset 49994 3128018e878b
parent 49993 2f348babe30d
child 49995 27fd12eca557
transaction: run abort callback in all cases Previously, these possibly important callback were "forgotten" when running a quick rollback. This is now fixed, as the tests shown.
mercurial/transaction.py
tests/test-hook.t
--- a/mercurial/transaction.py	Tue Feb 14 18:59:04 2023 +0100
+++ b/mercurial/transaction.py	Tue Feb 14 20:04:17 2023 +0100
@@ -670,6 +670,12 @@
 
         quick = self._can_quick_abort(entries)
         try:
+            if not quick:
+                self._report(_(b"transaction abort!\n"))
+            for cat in sorted(self._abortcallback):
+                self._abortcallback[cat](self)
+            # Prevent double usage and help clear cycles.
+            self._abortcallback = None
             if quick:
                 self._do_quick_abort(entries)
             else:
@@ -699,12 +705,7 @@
 
     def _do_full_abort(self, entries):
         """(Noisily) rollback all the change introduced by the transaction"""
-        self._report(_(b"transaction abort!\n"))
         try:
-            for cat in sorted(self._abortcallback):
-                self._abortcallback[cat](self)
-            # Prevent double usage and help clear cycles.
-            self._abortcallback = None
             _playback(
                 self._journal,
                 self._report,
--- a/tests/test-hook.t	Tue Feb 14 18:59:04 2023 +0100
+++ b/tests/test-hook.t	Tue Feb 14 20:04:17 2023 +0100
@@ -644,6 +644,15 @@
   HG_TXNNAME=push
   HG_URL=file:$TESTTMP/a
   
+  txnabort Python hook: bundle2,changes,source,txnid,txnname,url
+  txnabort hook: HG_BUNDLE2=1
+  HG_HOOKNAME=txnabort.1
+  HG_HOOKTYPE=txnabort
+  HG_SOURCE=push
+  HG_TXNID=TXN:$ID$
+  HG_TXNNAME=push
+  HG_URL=file:$TESTTMP/a
+  
   abort: prepushkey hook exited with status 1
   [40]
   $ cd ../a