Note:

This page is primarily intended for developers of Mercurial.

Revset Operators Plan

With new revset functions comes new workflows and the desire to quickly enter them. This page serves as a discussion for proposed operators. Currently, we have the following operators:

Operator

Function

!

not

::

DAG

:

range

&

and

|

or

-

set difference

^

parent

~

ancestor

Good candidates (i.e. not needing annoying shell escaping) for new operators:

=
{
}
/
% (bad for windows scripts)
? (interpreted by bash)
, (already used in function)

Other candidates,

#
$
\
[
]
;
_

One possibility is that we could have two character operators.

only()

This function is extremely handy and allows a quick way to view your current branch. The suggested operator is % (as in mod) though it might make more sense to use a set difference operator. For example,

only(.,@) → .%@
only(@) → @%

On Windows, '%' is a semi-reserved symbol in the following way: using non-bash shells (e.g. cmd.exe but NOT PowerShell, ConEmu, and cmder), %var% is only expanded when 'var' exists and is surrounded by '%'. For example, %home% (case insensitive) is automatically defined, so we get this:

C:\> echo .%home
.%home
C:\> echo .%home%
.C:\Users\sfarley

C:\> echo .%foo
.%foo
C:\> echo .%foo%
.%foo%

Following from this stack overflow answer, it would appear that '%' would work on the command-line and only be problematic in a batch script when conflicting with a variable of the same name.

Another operator could be \ (as in set difference from mathematics),

only(.,@) → .\\@
only(@) → @\\

children()

Navigating history is much easier if there is a way to say 'first child'. One proposal was to overload the parent operator ^ to use negative numbers but that could led to confusion since children are not defined to have an order.

next()

This function does not yet exist but it could possibly provide the convenience of a child operator.

ideas from mpm

Putting here for posterity: http://markmail.org/message/sjnnwa43s4eksu62


CategoryDeveloper CategoryNewFeatures

RevsetOperatorPlan (last edited 2017-05-31 03:55:15 by Sean Farley)