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

Martijn Pieters mj at zopatista.com
Wed May 18 12:15:10 EDT 2016


On 18 May 2016 at 15:44, Pierre-Yves David
<pierre-yves.david at ens-lyon.org> wrote:
> Why is this a new predicate instead of a key for the 'sort' revset? This
> would seems more appropriate.

sort() can sort on more than one key; e.g. sort(set, "-date author")
to sort in reverse date order (newest first), then within each date,
by author in alphabetical order. It makes no sense to apply a toposort
to any of the other sort orders; note that the algorithm requires the
revisions to be sorted in revision order!

Rather than cram toposort into the sort() but then have to explain
that when you use 'topo' as a sort key the other keys must be ignored,
it was much cleaner to create a separate predicate.

toposort() also needs to accept the firstbranch argument; it would
have required adding a third to sort() that only applies to just one
type of sort.

> Could we move the code around in an independant patch this would make
> actual new code introduction and change easier to track.

I adapted your code slightly to fit a predicate. I'm not sure that the
move from graphmod.py to revset.py makes any sense without the
changes.

-- 
Martijn Pieters


More information about the Mercurial-devel mailing list