[PATCH 1 of 5 V2] revsets: record sort order keys

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Jun 2 01:55:26 UTC 2016



On 05/30/2016 02:56 PM, Yuya Nishihara wrote:
> On Sun, 29 May 2016 09:57:34 -0700, Martijn Pieters wrote:
>> On 26 May 2016 at 06:00, Yuya Nishihara <yuya at tcha.org> wrote:
>>> This patch seems to try hard to preserve raw sort key strings, but they
>>> aren't exactly the same as what sort() would do. That made me feel keeping
>>> raw sort keys wouldn't be nice.
>>
>> They produce sorted output that still honours the (informative) sort
>> key. I could add a clarification to the docstring here that
>> `reversed(sort(set, keys))` produces slightly different output from
>> `sort(set, reversedkeys)` where the input order is reversed for any
>> entry where the sort keys are equal. If someone cares about the sort
>> order beyond the sort keys they need to re-sort explicitly.
> 
> Perhaps nobody would care that. We only care 'rev', '-rev' and 'topo' right
> now, and the first two are .isascending() and .isdescending(). We could
> introduce a general .sortorder attribute at the cost of boring string
> manipulation, but I don't see it would be useful. Plus, it doesn't always
> agree with sort(). That's why I thought .istopo() would be simpler.

In addition a "sortorder" attribute would be less expressive than
multiple booleans. For example, a set of 1 or less element is both
ascending, descending and topo sorted!

> BTW, we'll have to normalize 'author' and 'user'.
> 
>>> Perhaps adding istopo() or something would be simpler.
>>
>> You'd still have to track that across multiple predicates; I tried
>> that as a first step but it wasn't any simpler really.
> 
> I meant set.istopo() in place of set.sortorder. I didn't mean
> istopo(revset_expr), which would be doable but not simple because multiple
> predicates may be reordered by their weights.

For what it is worth, I like Yuya's "istopo" idea. I wonder it someone
will want the oposite (ensure no children is issued before its parent).
This lead me to wonder if we could find a better name than "istopo".

Cheers,

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list