diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -75,9 +75,14 @@ def _revancestors(repo, revs, followfirs if current not in seen: seen.add(current) yield current - for parent in cl.parentrevs(current)[:cut]: - if parent != node.nullrev: - heapq.heappush(h, -parent) + try: + for parent in cl.parentrevs(current)[:cut]: + if parent != node.nullrev: + heapq.heappush(h, -parent) + except error.WdirUnsupported: + for parent in repo[current].parents()[:cut]: + if parent.rev() != node.nullrev: + heapq.heappush(h, -parent.rev()) return generatorset(iterate(), iterasc=False) diff --git a/tests/test-revset.t b/tests/test-revset.t --- a/tests/test-revset.t +++ b/tests/test-revset.t @@ -1231,6 +1231,16 @@ Test working-directory revision 2147483647 $ hg debugrevspec 'wdir()~3' 5 + $ hg debugrevspec 'ancestors(wdir())' + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 2147483647 $ hg debugrevspec 'wdir()~0' 2147483647 $ hg debugrevspec 'p1(wdir())'