diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -206,7 +206,8 @@ def p1(repo, subset, x): First parent of changesets in set, or the working directory. """ if x is None: - return [repo[x].parents()[0].rev()] + p = repo[x].parents()[0].rev() + return [r for r in subset if r == p] ps = set() cl = repo.changelog @@ -221,7 +222,8 @@ def p2(repo, subset, x): if x is None: ps = repo[x].parents() try: - return [ps[1].rev()] + p = ps[1].rev() + return [r for r in subset if r == p] except IndexError: return [] @@ -237,7 +239,8 @@ def parents(repo, subset, x): """ repo.ui.debug(repr(x), '\n') if x is None: - return [r.rev() for r in repo[x].parents()] + ps = tuple(p.rev() for p in repo[x].parents()) + return [r for r in subset if r in ps] ps = set() cl = repo.changelog diff --git a/tests/test-revset-dirstate-parents.t b/tests/test-revset-dirstate-parents.t --- a/tests/test-revset-dirstate-parents.t +++ b/tests/test-revset-dirstate-parents.t @@ -14,9 +14,11 @@ $ try 'p1()' ('func', ('symbol', 'p1'), None) - -1 $ try 'p2()' ('func', ('symbol', 'p2'), None) + $ try 'parents()' + ('func', ('symbol', 'parents'), None) + None null revision $ log 'p1()' @@ -28,9 +30,11 @@ working dir with a single parent $ hg ci -Aqm0 $ log 'p1()' 0 + $ log 'tag() and p1()' $ log 'p2()' $ log 'parents()' 0 + $ log 'tag() and parents()' merge in progress $ echo b > b @@ -43,6 +47,7 @@ merge in progress 2 $ log 'p2()' 1 + $ log 'tag() and p2()' $ log 'parents()' + 1 2 - 1