diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -632,7 +632,10 @@ def commonancestors(repo, subset, x): """ # only wants the heads of the set passed in - for r in heads(repo, fullreposet(repo), x, anyorder): + h = heads(repo, fullreposet(repo), x, anyorder) + if not h: + return baseset() + for r in h: subset &= dagop.revancestors(repo, baseset([r])) return subset diff --git a/tests/test-revset.t b/tests/test-revset.t --- a/tests/test-revset.t +++ b/tests/test-revset.t @@ -1063,6 +1063,12 @@ test common ancestors 8 9 +test ancestor variants of empty revision + + $ log 'ancestor(none())' + $ log 'ancestors(none())' + $ log 'commonancestors(none())' + test ancestors with depth limit (depth=0 selects the node itself)