diff mercurial/localrepo.py @ 34709:c212947273a7

bookmark: add a dedicated pretxnclose-bookmark hook This new hook mirror the newly introduced 'txnclose-bookmark' but can abort the transaction.
author Boris Feld <boris.feld@octobus.net>
date Sun, 08 Oct 2017 18:50:14 +0200
parents ee5f0d047b41
children cdf833d7de98
line wrap: on
line diff
--- a/mercurial/localrepo.py	Tue Oct 10 17:53:42 2017 +0200
+++ b/mercurial/localrepo.py	Sun Oct 08 18:50:14 2017 +0200
@@ -1235,8 +1235,17 @@
             # This will have to be fixed before we remove the experimental
             # gating.
             tracktags(tr2)
-            reporef().hook('pretxnclose', throw=True,
-                           txnname=desc, **pycompat.strkwargs(tr.hookargs))
+            repo = reporef()
+            if hook.hashook(repo.ui, 'pretxnclose-bookmark'):
+                for name, (old, new) in sorted(tr.changes['bookmarks'].items()):
+                    args = tr.hookargs.copy()
+                    args.update(bookmarks.preparehookargs(name, old, new))
+                    repo.hook('pretxnclose-bookmark', throw=True,
+                              txnname=desc,
+                              **pycompat.strkwargs(args))
+
+            repo.hook('pretxnclose', throw=True,
+                      txnname=desc, **pycompat.strkwargs(tr.hookargs))
         def releasefn(tr, success):
             repo = reporef()
             if success: