hgext/inhibit.py
changeset 1560 59d47a9f633d
parent 1551 40e496bc7b54
child 1564 42c30774e63d
--- a/hgext/inhibit.py	Fri Dec 11 10:51:04 2015 +0000
+++ b/hgext/inhibit.py	Thu Dec 10 15:34:34 2015 -0800
@@ -22,6 +22,7 @@
 from mercurial import scmutil
 from mercurial import commands
 from mercurial import lock as lockmod
+from mercurial import bookmarks
 from mercurial import util
 from mercurial.i18n import _
 
@@ -72,6 +73,13 @@
     finally:
         lockmod.release(wlock)
 
+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)
+
 def _bookmark(orig, ui, repo, *bookmarks, **opts):
     """ Add a -D option to the bookmark command, map it to prune -B """
     haspruneopt = opts.get('prune', False)
@@ -255,6 +263,10 @@
                                     _computeobsoletenotrebasedwrap)
     except KeyError:
         pass
+    # 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)
     # Add bookmark -D option
     entry = extensions.wrapcommand(commands.table, 'bookmark', _bookmark)
     entry[1].append(('D','prune',None,