[PATCH 1 of 3 gca-revset V2] revsets: add commonancestors revset
Yuya Nishihara
yuya at tcha.org
Wed Jun 27 08:15:21 EDT 2018
On Tue, 26 Jun 2018 15:40:37 -0700, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean at farley.io>
> # Date 1529376114 25200
> # Mon Jun 18 19:41:54 2018 -0700
> # Branch gca-revset
> # Node ID 33336034db436af9b15237bb87f82405eb039dfb
> # Parent 2f5c622fcb739aed795c9ab51ea69c3b46436054
> revsets: add commonancestors revset
> + at predicate('commonancestors(set)', safe=True)
> +def commonancestors(repo, subset, x):
> + """Returns all common ancestors of the set.
> +
> + This method is for calculating "::x and ::y" (i.e. all the ancestors that
> + are common to both x and y) in an easy and optimized way. We can't quite
> + use "::head()" but that revset returns "::x + ::y + ..." for each head in
> + the repo (whereas we want "::x *and* ::y").
> +
> + """
> + # only wants the heads of the set passed in
> + h = heads(repo, subset, x)
^^^^^^
Perhaps it should be fullreposet(repo) since the subset has to be filtered by
any heads which may be out of the subset.
> + commonrevs = repo.revs(" and ".join(["::%s"] * len(h), *h))
^^^^^^^
Bad parens. And this wouldn't work if h is empty. Instead, we can chain
ancestor revisions.
for r in heads(...):
subset &= dagop.revancestors(repo, baseset([r]))
More information about the Mercurial-devel
mailing list