# HG changeset patch # User Yuya Nishihara # Date 1537961589 -32400 # Node ID 85a474adaf26d07c408a956c7e5d7d7c0eff072a # Parent 7a9e2d85f475b1675da537ece26419887f9d8b4e# Parent 823f34acfd46eb74d362e819d1cc3475bf05bf2f merge with stable diff -r 7a9e2d85f475 -r 85a474adaf26 mercurial/revset.py --- 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) diff -r 7a9e2d85f475 -r 85a474adaf26 tests/test-revset.t --- 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