# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 2017-05-22 19:52:33 # Node ID 4dd292cec3adaa52afce2b281a8b76610e7a595d # Parent 018f638ad88ebe4b87733ebaff82489caa9bc951 revset: add support for ancestors(wdir()) This is a part of extending support for wdir() predicate. 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())'