hgext/inhibit.py
changeset 1234 c15d4677f2ba
parent 1233 63ee05dd557a
child 1240 e1347ce2f954
--- a/hgext/inhibit.py	Mon Mar 30 11:45:17 2015 -0700
+++ b/hgext/inhibit.py	Mon Mar 30 13:31:09 2015 -0700
@@ -29,6 +29,7 @@
 from mercurial import revset
 from mercurial import error
 from mercurial import commands
+from mercurial import bookmarks
 
 cmdtable = {}
 command = cmdutil.command(cmdtable)
@@ -61,6 +62,12 @@
     _inhibitmarkers(repo, [newhead])
     return res
 
+def _bookmarkchanged(orig, bkmstoreinst, *args, **kwargs):
+    """ Add inhibition markers to every obsolete bookmarks """
+    repo = bkmstoreinst._repo
+    bkmstorenodes = [repo[v].node() for v in bkmstoreinst.values()]
+    _inhibitmarkers(repo, bkmstorenodes)
+    return orig(bkmstoreinst, *args, **kwargs)
 
 # obsolescence inhibitor
 ########################
@@ -154,6 +161,11 @@
     # wrap update to make sure that no obsolete commit is visible after an
     # update
     extensions.wrapcommand(commands.table, 'update', _update)
+    # There are two ways to save bookmark changes during a transation, we
+    # wrap both to add inhibition markers.
+    extensions.wrapfunction(bookmarks.bmstore, 'recordchange', _bookmarkchanged)
+    extensions.wrapfunction(bookmarks.bmstore, 'write', _bookmarkchanged)
+
 
 def gethashsymbols(tree):
     # Returns the list of symbols of the tree that look like hashes