[PATCH 4 of 5 V2] revset: use delayregistrar to register predicate in extension easily

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Fri Jan 1 23:30:14 CST 2016


At Sat, 02 Jan 2016 01:28:28 +0900,
FUJIWARA Katsunori wrote:
> 
> At Fri, 1 Jan 2016 17:53:10 +0900,
> Yuya Nishihara wrote:
> > 
> > On Wed, 30 Dec 2015 00:08:51 +0900, FUJIWARA Katsunori wrote:
> > > # HG changeset patch
> > > # User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
> > > # Date 1451401110 -32400
> > > #      Tue Dec 29 23:58:30 2015 +0900
> > > # Node ID 0aa9cf12fc6ce052b0f2e91674d1c56fe6078939
> > > # Parent  a1e4c18851155866ab75a35aa5bbae81945d7db5
> > > revset: use delayregistrar to register predicate in extension easily
> > > 
> > > Previous patch introduced 'revset.predicate' decorator to register
> > > revset predicate function easily.
> > > 
> > > But it shouldn't be used in extension directly, because it registers
> > > specified function immediately. Registration itself can't be restored,
> > > even if extension loading fails after that.
> > > 
> > > Therefore, registration should be delayed until 'uisetup()' or so.
> > > 
> > > This patch uses 'extpredicate' decorator derived from 'delayregistrar'
> > > to register predicate in extension easily.
> > > 
> > > This patch also tests whether 'registrar.delayregistrar' avoids
> > > function registration if 'setup()' isn't invoked on it, because
> > > 'extpredicate' is the first user of it.
> > 
> > > --- a/hgext/mq.py
> > > +++ b/hgext/mq.py
> > > @@ -3558,9 +3558,11 @@ def summaryhook(ui, repo):
> > >          # i18n: column positioning for "hg summary"
> > >          ui.note(_("mq:     (empty queue)\n"))
> > >  
> > > +revsetpredicate = revset.extpredicate()
> > > +
> > > + at revsetpredicate('mq()')
> > >  def revsetmq(repo, subset, x):
> > > -    """``mq()``
> > > -    Changesets managed by MQ.
> > > +    """Changesets managed by MQ.
> > >      """
> > >      revset.getargs(x, 0, 0, _("mq takes no arguments"))
> > >      applied = set([repo[r.node].rev() for r in repo.mq.applied])
> > > @@ -3596,7 +3598,7 @@ def extsetup(ui):
> > >          if extmodule.__file__ != __file__:
> > >              dotable(getattr(extmodule, 'cmdtable', {}))
> > >  
> > > -    revset.symbols['mq'] = revsetmq
> > > +    revsetpredicate.setup()
> 
> Augie, could you drop this series from clowncopter if it is possible ?
> It will make re-work easy.

Oh, this series was already imported into master repo. I'll make
changes on recent tip, if needed :-)

----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy at lares.dti.ne.jp


More information about the Mercurial-devel mailing list