diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -1434,7 +1434,12 @@ def p2(repo, subset, x): ps = set() cl = repo.changelog for r in getset(repo, fullreposet(repo), x): - ps.add(cl.parentrevs(r)[1]) + try: + ps.add(cl.parentrevs(r)[1]) + except error.WdirUnsupported: + parents = repo[r].parents() + if len(parents) == 2: + ps.add(parents[1]) ps -= {node.nullrev} # XXX we should turn this into a baseset instead of a set, smartset may do # some optimizations from the fact this is a baseset. diff --git a/tests/test-revset.t b/tests/test-revset.t --- a/tests/test-revset.t +++ b/tests/test-revset.t @@ -1233,6 +1233,7 @@ Test working-directory revision 2147483647 $ hg debugrevspec 'p1(wdir())' 7 + $ hg debugrevspec 'p2(wdir())' $ hg debugrevspec 'parents(wdir())' 7 $ hg debugrevspec 'wdir()^1'