diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -319,8 +319,9 @@ def ancestor(repo, subset, x): for r in reviter: anc = anc.ancestor(repo[r]) - if anc.rev() in subset: - return baseset([anc.rev()]) + r = scmutil.intrev(anc) + if r in subset: + return baseset([r]) return baseset() def _ancestors(repo, subset, x, followfirst=False, startdepth=None, diff --git a/tests/test-revset.t b/tests/test-revset.t --- a/tests/test-revset.t +++ b/tests/test-revset.t @@ -1813,6 +1813,16 @@ Test working-directory revision 6 7 2147483647 + $ hg debugrevspec '0:wdir() & ancestor(wdir())' + 2147483647 + $ hg debugrevspec '0:wdir() & ancestor(.:wdir())' + 4 + $ hg debugrevspec '0:wdir() & ancestor(wdir(), wdir())' + 2147483647 + $ hg debugrevspec '0:wdir() & ancestor(wdir(), tip)' + 4 + $ hg debugrevspec 'null:wdir() & ancestor(wdir(), null)' + -1 $ hg debugrevspec 'wdir()~0' 2147483647 $ hg debugrevspec 'p1(wdir())'