[PATCH 2 of 3 gca-revset V2] revset: add optimization for heads(commonancestors())

Yuya Nishihara yuya at tcha.org
Wed Jun 27 08:40:39 EDT 2018


On Tue, 26 Jun 2018 15:40:38 -0700, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean at farley.io>
> # Date 1530051981 25200
> #      Tue Jun 26 15:26:21 2018 -0700
> # Branch gca-revset
> # Node ID 0bab83973dbaecf03167801ddc4550c4b8b581f1
> # Parent  33336034db436af9b15237bb87f82405eb039dfb
> revset: add optimization for heads(commonancestors())

> +from .ancestor import commonancestorsheads

symbol import isn't allowed.

> +# for internal use
> + at predicate('_commonancestorheads(set)', safe=True)
> +def _commonancestorheads(repo, subset, x):
> +    """Returns all greatest common ancestors of the changesets.
> +
> +    This is an internal method is for quickly calculating "heads(::x and ::y)"
> +
> +    These greatest common ancestors are the same ones that the consesus bid
> +    merge will find.
> +    """

This has to be a comment. All docstrings are visible in the revset help.

> +    h = heads(repo, subset, x)
                       ^^^^^^
                       fullreposet(repo)

heads may be out of the subset.

> +
> +    try:
> +        ancs = repo.changelog.index.commonancestorsheads(*list(h))
> +        return subset & baseset(ancs)
> +    except (AttributeError, OverflowError): # C implementation failed
> +        return subset & commonancestorsheads(repo.changelog.parentrevs,
> +                                             *list(h))


More information about the Mercurial-devel mailing list