diff mercurial/localrepo.py @ 24792:7d0421de8de3

hooks: add a 'txnabort' hook This hook will be called whenever a transaction is aborted. This will make it easy for people to clean up temporary content they may have created during a transaction.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 16 Apr 2015 05:36:49 -0400
parents 59406b8b1303
children 9fbf0a2a72a1
line wrap: on
line diff
--- a/mercurial/localrepo.py	Thu Apr 16 05:41:07 2015 -0400
+++ b/mercurial/localrepo.py	Thu Apr 16 05:36:49 2015 -0400
@@ -975,6 +975,12 @@
                                **tr2.hookargs)
             reporef()._afterlock(hook)
         tr.addfinalize('txnclose-hook', txnclosehook)
+        def txnaborthook(tr2):
+            """To be run if transaction is aborted
+            """
+            reporef().hook('txnabort', throw=False, txnname=desc,
+                           **tr2.hookargs)
+        tr.addabort('txnabort-hook', txnaborthook)
         self._transref = weakref.ref(tr)
         return tr