Mercurial > hg
changeset 38705:e4b270a32ba8
revset: special case commonancestors(none()) to be empty set
This matches the behavior of ancestor(none()).
From an implementation perspective, ancestor() and commonancestors() are
intersection, and ancestors() is union, so it would make some sense that
commonancestors(none()) returned all revisions. However, ancestor(none())
isn't implemented as such, which breaks ancestor(x) == max(commonancestors(x)).
From a user perspective, ancestors of nothing is nothing whichever type
of operation the ancestor predicate does.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 12 Jul 2018 23:07:29 +0900 |
parents | 607e2a2501e6 |
children | 83d965803325 |
files | mercurial/revset.py tests/test-revset.t |
diffstat | 2 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revset.py Tue Jul 10 23:01:53 2018 +0900 +++ b/mercurial/revset.py Thu Jul 12 23:07:29 2018 +0900 @@ -632,7 +632,10 @@ """ # 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
--- a/tests/test-revset.t Tue Jul 10 23:01:53 2018 +0900 +++ b/tests/test-revset.t Thu Jul 12 23:07:29 2018 +0900 @@ -1063,6 +1063,12 @@ 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)