Skip to content

FR: Add merge_point() and forks() revset functions #8643

@scott2000

Description

@scott2000

Is your feature request related to a problem? Please describe.
Currently, we have a set of revset functions that work on ancestors, and a separate set of revset functions that work on descendants. We can think of these pairs of functions as being equivalent, just with the "descendants"-based functions acting on a graph with all edges reversed compared to the "ancestors"-based functions:

Ancestors-based Descendants-based
ancestors(x, [depth]) descendants(x, [depth])
parents(x, [depth]) children(x, [depth])
heads(x) roots(x)
fork_point(x) -
merges() -

It looks like we're missing "descendants"-based equivalents to fork_point() and merges().

Describe the solution you'd like
Add two new revset functions:

  • merge_point(x) - Equivalent to roots(x_1:: & x_2:: & ... & x_N::). Whereas fork_point(a | b) can be used to find where two branches forked from each other, merge_point(a | b) can be used to find where two branches merged together (if any such commit exists).
  • forks() - Whereas merges() returns commits with multiple parents, forks() returns commits with multiple children.

This naming also leads to the nice property that fork_point(x) always returns commits from forks(), while merge_point(x) always returns commits from merges().

Describe alternatives you've considered
These functions are likely less useful than their "ancestors"-based counterparts and also a bit more difficult to implement, so we could choose not to implement them.

We could also use different naming; forks() might be confused for the concept of a forked repository, but I'm not sure what a better name would be.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions