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.
--- 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