diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -1621,7 +1621,7 @@ def parentspec(repo, subset, x, n, order ps.add(cl.parentrevs(r)[0]) elif n == 2: parents = cl.parentrevs(r) - if len(parents) > 1: + if parents[1] != node.nullrev: ps.add(parents[1]) return subset & ps diff --git a/tests/test-revset.t b/tests/test-revset.t --- a/tests/test-revset.t +++ b/tests/test-revset.t @@ -2750,6 +2750,7 @@ parentrevspec 5 $ log 'merge()^2' 4 + $ log '(not merge())^2' $ log 'merge()^^' 3 $ log 'merge()^1^'