[PATCH] revset: add experimental set subscript operator

Jun Wu quark at fb.com
Fri Jul 7 13:43:39 EDT 2017


Excerpts from Yuya Nishihara's message of 2017-07-08 01:11:50 +0900:
> Just a nitpick. They are quite different operations if we take the #op
> as an order specifier.
> 
>  x[y] (indexing) selects the y-th element from x (inside x)
>  x{y} goes to the y-th elements from x (outside x)
> 
> But, ...

Good catch. Then it makes sense to use different operators.

I wonder if we have some real world examples of "y-th element from x". I
couldn't really think of good convincing examples so it might be an
operation we don't provide intentionally.

> We could read 'x#op' as 'x->op()' in C++, so 'x#changelog' could be considered
> 'ancestors(x) + descendants(x)' operation with depth index.
>
> Perhaps, a drawback of this idea is that the syntax is verbose, and parsing
> will be a bit complex.

Maybe allow them to be shorter, like "#c", "#l", "#o". Then it is only one
character longer than "[1c]", "[1l]", "[1o]". I think the latter also looks
good. The key difference would be whether we want "[]" to be like existing
language or not.

Slightly off-topic, I wonder if we can make "#o", "#l" or "#c" without "[]"
something useful, like "hg log -r 'x#o'" could imply "using the obsolete
graph, "hg log -rf 'x#l'" means "using the linear graph". It feels like an
extra bit of information similar to "istopo". I have been thinking about
"log --dag DAGTYPE". This might be a way to embed the flag into revset, just
like other log flags.


More information about the Mercurial-devel mailing list