diff mercurial/bookmarks.py @ 34708:ee5f0d047b41

bookmark: add a dedicated txnclose-bookmark hook The new 'txnclose-bookmark' hook expose the bookmark movement information stored in 'tr.changes['bookmarks]'. To provide a simple and straightforward hook API to the users, we introduce a new hook called for each bookmark touched. Since a transaction can affect multiple bookmarks, updating the existing 'txnclose' hook to expose that information would be more complex. The data for all moves might not fit in environment variables and iterations over each move would be cumbersome. So the introduction of a new dedicated hook is preferred in this changeset. This does not exclude the addition to the full bookmark information to the existing 'txnclose' in the future to help write more complex hooks.
author Boris Feld <boris.feld@octobus.net>
date Tue, 10 Oct 2017 17:53:42 +0200
parents 712a85b3677f
children 3340d46a5c3f
line wrap: on
line diff
--- a/mercurial/bookmarks.py	Fri Oct 13 15:58:54 2017 -0400
+++ b/mercurial/bookmarks.py	Tue Oct 10 17:53:42 2017 +0200
@@ -846,3 +846,12 @@
 
         bmarks[bmark] = (n, prefix, label)
     _printbookmarks(ui, repo, bmarks, **opts)
+
+def preparehookargs(name, old, new):
+    if new is None:
+        new = ''
+    if old is None:
+        old = ''
+    return {'bookmark': name,
+            'node': hex(new),
+            'oldnode': hex(old)}