revset: fix ancestor subset handling (
issue2298)
--- a/mercurial/revset.py Mon Jul 12 16:07:58 2010 +0200
+++ b/mercurial/revset.py Thu Jul 22 08:17:38 2010 -0500
@@ -223,11 +223,14 @@
def ancestor(repo, subset, x):
l = getargs(x, 2, 2, _("ancestor wants two arguments"))
- a = getset(repo, subset, l[0])
- b = getset(repo, subset, l[1])
- if len(a) > 1 or len(b) > 1:
+ r = range(len(repo))
+ a = getset(repo, r, l[0])
+ b = getset(repo, r, l[1])
+ if len(a) != 1 or len(b) != 1:
raise error.ParseError(_("ancestor arguments must be single revisions"))
- return [repo[a[0]].ancestor(repo[b[0]]).rev()]
+ an = [repo[a[0]].ancestor(repo[b[0]]).rev()]
+
+ return [r for r in an if r in subset]
def ancestors(repo, subset, x):
args = getset(repo, range(len(repo)), x)
--- a/tests/test-revset Mon Jul 12 16:07:58 2010 +0200
+++ b/tests/test-revset Thu Jul 22 08:17:38 2010 -0500
@@ -94,6 +94,7 @@
log 'ancestor(1)'
log 'ancestor(4,5)'
+log 'ancestor(4,5) and 4'
log 'ancestors(5)'
log 'author(bob)'
log 'branch(é)'
--- a/tests/test-revset.out Mon Jul 12 16:07:58 2010 +0200
+++ b/tests/test-revset.out Thu Jul 22 08:17:38 2010 -0500
@@ -93,6 +93,7 @@
hg: parse error: ancestor wants two arguments
% log 'ancestor(4,5)'
1
+% log 'ancestor(4,5) and 4'
% log 'ancestors(5)'
0
1