[PATCH] revset: define successors revset
Yuya Nishihara
yuya at tcha.org
Mon Jul 10 08:59:46 EDT 2017
On Sat, 8 Jul 2017 18:24:09 -0700, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1499563232 25200
> # Sat Jul 08 18:20:32 2017 -0700
> # Node ID 94977b4b9787d8709bc3ef7e4ae5ae5410961e5a
> # Parent 4672db164c986da4442bd864cd044512d975c3f2
> # Available At https://bitbucket.org/quark-zju/hg-draft
> # hg pull https://bitbucket.org/quark-zju/hg-draft -r 94977b4b9787
> revset: define successors revset
>
> This revset returns all successors, including transit nodes.
>
> To filter out transit nodes, use `successors(X)-obsolete()`.
> To filter out divergent case, use `successors(X)-divergent()-obsolete()`.
>
> The revset could be useful to define rebase destination, like:
> `max(successors(BASE)-divergent()-obsolete())`. The `max` is to deal with
> splits.
>
> There are other implementations where `successors` returns just one level of
> successors, and `allsuccessors` returns everything. I think `successors`
> returning all successors by default is more user friendly. We have seen
> cases in production where people use 1-level `successors` while they really
> want `allsuccessors`. So I think it's better to just have one single revset
> returning all successors by default to avoid user errors.
Sounds good.
> In the future we might want to add `depth` keyword argument to it and for
> other revsets like `ancestors` etc. Or even build fancy indexing syntax [1]
> to satisfy people having the level limit requirement.
[...]
> + at predicate('successors(set)', safe=True)
> +def successors(repo, subset, x):
> + """All successors for given set"""
> + s = getset(repo, fullreposet(repo), x)
> + f = lambda nodes: obsutil.allsuccessors(repo.obsstore, nodes)
> + d = _mapbynodefunc(repo, s, f) - s
> + return subset & d
If we'll eventually add a depth parameter, I think successors(set) should
include the given set itself for consistency with ancesotrs()/descendants().
More information about the Mercurial-devel
mailing list