[PATCH RFC] revset: lookup descendents for negative arguments to ancestor operator

Sean Farley sean at farley.io
Tue May 30 23:57:35 EDT 2017

David Soria Parra <davidsp at fb.com> writes:

> # HG changeset patch
> # User David Soria Parra <davidsp at fb.com>
> # Date 1495905909 25200
> #      Sat May 27 10:25:09 2017 -0700
> # Node ID 47c710c797624b6d5c84c493a873ea8beb563a74
> # Parent  b647b923486f38d83b92089eafa9faafaa79785d
> revset: lookup descendents for negative arguments to ancestor operator
> Negative offsets to the `~` operator now search for descendents. The search is
> aborted when a node has more than one child as we do not have a definition for
> 'nth child'. Optionally we can introduce such a notion and take the nth child
> ordered by rev number.
> The current revset language does provides a short operator for ancestor lookup
> but not for descendents. This gives user a simple revset to move to the previous
> changeset, e.g. `hg up '.~1'` but not to the 'next' changeset. With this change
> userse can now use `.~-1` as a shortcut to move to the next changeset.
> This fits better into allowing users to specify revisions via revsets and
> avoiding the need for special `hg next` and `hg prev` operations.

Thanks for picking this back up! Back in the day, I had an idea for this
that was: x^-1 (first child), x^-2 (second child; ordered by rev num)
since that seems to be symmetric to what we have now.

x^-1^-1 would then be equivalent to x~-2. This eventually all got
derailed before and during the last London sprint when mpm suggested the

(added to https://www.mercurial-scm.org/wiki/RevsetOperatorPlan)


Nothing ever came of it but it might provide some insight into previous
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 800 bytes
Desc: not available
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20170530/4adb0667/attachment.sig>

More information about the Mercurial-devel mailing list