# HG changeset patch # User Patrick Mezard # Date 2010-11-07 17:14:42 # Node ID 98b79c89276857fb38da975994885825b570801d # Parent 7a2bca0b1e70cccf0edf0a15dcf45088551daeb3 revset: fix p1, p2 and parents in dirstate case (a5f7f1e9340e) - Handle 'subset' argument - Stop returning the null rev from p1 and parents, as in the non-dirstate case - Order parents as in the non-dirstate case (ascending revs) 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