[PATCH 5 of 5 V3] revset: replace predicate by revsetpredicate of registrar

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Wed Mar 9 01:10:58 EST 2016


At Tue, 08 Mar 2016 23:12:32 +0000,
Martin von Zweigbergk wrote:
> 
> [1  <text/plain; UTF-8 (7bit)>]
> On Tue, Mar 8, 2016 at 10:56 AM Augie Fackler <raf at durin42.com> wrote:
> 
> > On Tue, Mar 08, 2016 at 11:08:27PM +0900, FUJIWARA Katsunori wrote:
> > > # HG changeset patch
> > > # User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
> > > # Date 1457445893 -32400
> > > #      Tue Mar 08 23:04:53 2016 +0900
> > > # Node ID e66468a1adffedd602a098e48a527d387a05de3a
> > > # Parent  757d7e1c69a80d27f0f8ab0ad7609a864cfe3120
> > > revset: replace predicate by revsetpredicate of registrar
> >
> > These are queued, thanks.
> >
> > I believe this series will break any third-party extensions that
> > register revsets, is that right?
> >
> 
> The extpredicate class is still there, and that's apparently what
> third-party extensions should use, so maybe not?
> 

(Original) revset.predicate and revset.extpredicate were released
silently at 3.7, just previous major release.

Therefore, this (and subsequent series, which removes
"revset.extpredicate") seems not to cause serious compatibility
problem (please see below discussion just before 3.7 code freeze, too).

    https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-January/078599.html

I'll write about usage of registrar into WritingExtensions wiki page,
one by one for each types (revset, fileset, templatekeyword and so
on).


> (I found the extpredicate last night and noticed that the code I recently
> added to our Google-internal extension does not use it :-(.)

So, please forget about revset.extpredicate and use
registrar.revsetpredicate for third party extension :-)



> > >
> > > To make all built-in predicates be known to hggettext, loading
> > > built-in predicates by loadpredicate() should be placed before fixing
> > > i18nfunctions but after all of predicate decorating.
> > >
> > > diff --git a/mercurial/revset.py b/mercurial/revset.py
> > > --- a/mercurial/revset.py
> > > +++ b/mercurial/revset.py
> > > @@ -482,36 +482,7 @@ symbols = {}
> > >  # functions that just return a lot of changesets (like all) don't count
> > here
> > >  safesymbols = set()
> > >
> > > -class predicate(registrar.funcregistrar):
> > > -    """Decorator to register revset predicate
> > > -
> > > -    Usage::
> > > -
> > > -        @predicate('mypredicate(arg1, arg2[, arg3])')
> > > -        def mypredicatefunc(repo, subset, x):
> > > -            '''Explanation of this revset predicate ....
> > > -            '''
> > > -            pass
> > > -
> > > -    The first string argument of the constructor is used also in
> > > -    online help.
> > > -
> > > -    Use 'extpredicate' instead of this to register revset predicate in
> > > -    extensions.
> > > -    """
> > > -    table = symbols
> > > -    formatdoc = "``%s``\n    %s"
> > > -    getname = registrar.funcregistrar.parsefuncdecl
> > > -
> > > -    def __init__(self, decl, safe=False):
> > > -        """'safe' indicates whether a predicate is safe for DoS attack
> > > -        """
> > > -        super(predicate, self).__init__(decl)
> > > -        self.safe = safe
> > > -
> > > -    def extraaction(self, name, func):
> > > -        if self.safe:
> > > -            safesymbols.add(name)
> > > +predicate = registrar.revsetpredicate()
> > >
> > >  class extpredicate(registrar.delayregistrar):
> > >      """Decorator to register revset predicate in extensions
> > > @@ -3636,5 +3607,8 @@ def loadpredicate(ui, extname, registrar
> > >          if func._safe:
> > >              safesymbols.add(name)
> > >
> > > +# load built-in predicates explicitly to setup safesymbols
> > > +loadpredicate(None, None, predicate)
> > > +
> > >  # tell hggettext to extract docstrings from these functions:
> > >  i18nfunctions = symbols.values()
> > > _______________________________________________
> > > Mercurial-devel mailing list
> > > Mercurial-devel at mercurial-scm.org
> > > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
> > _______________________________________________
> > Mercurial-devel mailing list
> > Mercurial-devel at mercurial-scm.org
> > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
> >
> [2  <text/html; UTF-8 (quoted-printable)>]
> 

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


More information about the Mercurial-devel mailing list