revset: add support for ancestors(wdir())
This is a part of extending support for wdir() predicate.
--- a/mercurial/revset.py Tue May 23 01:08:19 2017 +0530
+++ b/mercurial/revset.py Tue May 23 01:22:33 2017 +0530
@@ -75,9 +75,14 @@
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)
--- a/tests/test-revset.t Tue May 23 01:08:19 2017 +0530
+++ b/tests/test-revset.t Tue May 23 01:22:33 2017 +0530
@@ -1231,6 +1231,16 @@
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())'