Mercurial > hg
changeset 39832:85a474adaf26
merge with stable
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Wed, 26 Sep 2018 20:33:09 +0900 |
parents | 7a9e2d85f475 (current diff) 823f34acfd46 (diff) |
children | 28626957395a |
files | mercurial/revset.py tests/test-revset.t |
diffstat | 2 files changed, 28 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revset.py Tue Sep 25 22:19:40 2018 +0900 +++ b/mercurial/revset.py Wed Sep 26 20:33:09 2018 +0900 @@ -616,30 +616,22 @@ # 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 + # These greatest common ancestors are the same ones that the consensus bid # merge will find. - h = heads(repo, fullreposet(repo), x, anyorder) + startrevs = getset(repo, fullreposet(repo), x, order=anyorder) - ancs = repo.changelog._commonancestorsheads(*list(h)) + ancs = repo.changelog._commonancestorsheads(*list(startrevs)) return subset & baseset(ancs) @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()" because that revset returns "::x + ::y + ..." for each head - in the repo (whereas we want "::x *and* ::y"). - + """Changesets that are ancestors of every changeset in set. """ - # only wants the heads of the set passed in - h = heads(repo, fullreposet(repo), x, anyorder) - if not h: + startrevs = getset(repo, fullreposet(repo), x, order=anyorder) + if not startrevs: return baseset() - for r in h: + for r in startrevs: subset &= dagop.revancestors(repo, baseset([r])) - return subset @predicate('contains(pattern)', weight=100)
--- a/tests/test-revset.t Tue Sep 25 22:19:40 2018 +0900 +++ b/tests/test-revset.t Wed Sep 26 20:33:09 2018 +0900 @@ -1049,7 +1049,7 @@ 2 4 - $ hg log -T '{rev}\n' -r 'commonancestors(head())' + $ hg log -T '{rev}\n' -r 'commonancestors(heads(all()))' 0 1 2 @@ -1063,11 +1063,31 @@ 8 9 + $ hg log -T '{rev}\n' -r 'commonancestors(8 + 9)' + 0 + 1 + 2 + 4 + 8 + +test the specialized implementation of heads(commonancestors(..)) +(2 gcas is tested in test-merge-criss-cross.t) + + $ hg log -T '{rev}\n' -r 'heads(commonancestors(7 + 9))' + 4 + $ hg log -T '{rev}\n' -r 'heads(commonancestors(heads(all())))' + 4 + $ hg log -T '{rev}\n' -r 'heads(commonancestors(9))' + 9 + $ hg log -T '{rev}\n' -r 'heads(commonancestors(8 + 9))' + 8 + test ancestor variants of empty revision $ log 'ancestor(none())' $ log 'ancestors(none())' $ log 'commonancestors(none())' + $ log 'heads(commonancestors(none()))' test ancestors with depth limit