diff --git a/contrib/all-revsets.txt b/contrib/all-revsets.txt --- a/contrib/all-revsets.txt +++ b/contrib/all-revsets.txt @@ -23,8 +23,6 @@ parents(20000) # Used in revision 911f5a6579d1 p1(20000) p2(10000) -# Used in revision f140d6207cca -roots(0:tip) # Used in revision b6dc3b79bb25 0:: # Used in revision faf4f63533ff @@ -101,15 +99,12 @@ draft() ::tip draft() and ::tip ::tip and draft() -roots(0::tip) author(lmoscovicz) author(mpm) -42:68 and roots(42:tip) ::p1(p1(tip)):: public() :10000 and public() :10000 and draft() -roots((0:tip)::) (not public() - obsolete()) # The one below is used by rebase @@ -119,6 +114,18 @@ roots((0:tip)::) roots((tip~100::) - (tip~100::tip)) roots((0::) - (0::tip)) +# more roots testing +roots(tip~100:) +roots(:42) +roots(not public()) +roots((0:tip)::) +roots(0::tip) +42:68 and roots(42:tip) +# Used in revision f140d6207cca +roots(0:tip) +# test disjoint set with multiple roots +roots((:42) + (tip~42:)) + # Testing the behavior of "head()" in various situations head() head() - public() diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -1755,9 +1755,13 @@ def roots(repo, subset, x): Changesets in set with no parent changeset in set. """ s = getset(repo, fullreposet(repo), x) - subset = subset & s# baseset([r for r in s if r in subset]) - cs = _children(repo, subset, s) - return subset - cs + parents = repo.changelog.parentrevs + def filter(r): + for p in parents(r): + if 0 <= p and p in s: + return False + return True + return subset & s.filter(filter) def sort(repo, subset, x): """``sort(set[, [-]key...])``