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

Martin von Zweigbergk martinvonz at google.com
Tue Mar 8 18:12:32 EST 2016


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?

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


>
> >
> > 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20160308/f167b0da/attachment.html>


More information about the Mercurial-devel mailing list