[PATCH 3 of 3 V2] revsets: add new toposort predicate

Yuya Nishihara yuya at tcha.org
Sun May 22 09:57:37 EDT 2016


On Fri, 20 May 2016 18:44:12 +0100, Martijn Pieters wrote:
> On 20 May 2016 at 13:59, Yuya Nishihara <yuya at tcha.org> wrote:
> >> > Going along with the keyword arguments, you could extend this to use prefixes:
> >> >
> >> >     topo_firstbranch=...
> >> >     topo_grouplimit=...
> >> >
> >> >     author_first=...
> >> >
> >> >     branch_first=...  
> >
> > or we might want to extend the key arguments to support function-like syntax:
> >
> > % hg debugrevspec -v 'sort(a, topo, branch(first=stable))'
> > (func
> >   ('symbol', 'sort')
> >   (list
> >     ('symbol', 'a')
> >     ('symbol', 'topo')
> >     (func
> >       ('symbol', 'branch')
> >       (keyvalue
> >         ('symbol', 'first')
> >         ('symbol', 'stable')))))
> >
> > It will require some hack in optimize().  
> 
> I like this, but the comma is a big change from the current syntax.
> Currently the syntax for multiple keys is a string:
> 
>     sort(a, "author branch")
> 
> I suppose we can still support that too.

Yes.

> Does your syntax work for reverse sorts too:
> 
>     sort(a, topo, -branch(first=stable))
> 
> which currently parses out to
> 
> (func
>   ('symbol', 'sort')
>   (list
>     ('symbol', 'a')
>     ('symbol', 'topo')
>     (negate
>       (func
>         ('symbol', 'branch')
>         (keyvalue
>           ('symbol', 'first')
>           ('symbol', 'stable'))))))
> 
> Note the `negate`.
> 
> We could require reversing to be another argument:
> 
>     sort(a, topo, branch(reversed=True, first=stable))
> 
> but if we could retain the - prefix that'd be nicer I think.

Perhaps. Anyway we'll have to handle arguments of sort() differently in
optimize(), so it should be possible to rewrite 'negate'.

However, a bigger problem would be that this syntax might be confusing for
users. Currently there's no function that isn't evaluated to a set. Only
symbols and strings are allowed for non-set arguments.

Even though I've proposed it, I'm not sure I like it.


More information about the Mercurial-devel mailing list