Patchwork [evolve-ext] inhibit: backout 23a34dce5131 remove unused bookmark operation wrapping

login
register
mail settings
Submitter Laurent Charignon
Date Dec. 10, 2015, 11:34 p.m.
Message ID <5466978e969b47c0620f.1449790488@lcharignon-mbp.local>
Download mbox | patch
Permalink /patch/11965/
State Accepted
Headers show

Comments

Laurent Charignon - Dec. 10, 2015, 11:34 p.m.
# HG changeset patch
# User Laurent Charignon <lcharignon@fb.com>
# Date 1449790474 28800
#      Thu Dec 10 15:34:34 2015 -0800
# Node ID 5466978e969b47c0620f082b67bb340ead6fbb78
# Parent  ed63bf62ff02cf5a1c9c12841b3ed0dfa7eccf2c
inhibit: backout 23a34dce5131 remove unused bookmark operation wrapping

This breaks potentially a lot of things. Let's give a change to extensions
maintainers to adapt to the new bookmarks.write api before removing this code
right away.
Pierre-Yves David - Dec. 11, 2015, 11:31 a.m.
On 12/10/2015 11:34 PM, Laurent Charignon wrote:
> # HG changeset patch
> # User Laurent Charignon <lcharignon@fb.com>
> # Date 1449790474 28800
> #      Thu Dec 10 15:34:34 2015 -0800
> # Node ID 5466978e969b47c0620f082b67bb340ead6fbb78
> # Parent  ed63bf62ff02cf5a1c9c12841b3ed0dfa7eccf2c
> inhibit: backout 23a34dce5131 remove unused bookmark operation wrapping

Pushed to main, thanks.

Patch

diff --git a/hgext/inhibit.py b/hgext/inhibit.py
--- a/hgext/inhibit.py
+++ b/hgext/inhibit.py
@@ -22,6 +22,7 @@  from mercurial import error
 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 @@  def _update(orig, ui, repo, *args, **kwa
     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 @@  def extsetup(ui):
                                     _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,