Mercurial > hg-stable
changeset 38493:626d29c6e987
revset: leverage orset() to flatten ancestor() arguments
This also makes orset() accept an empty argument because nullary ancestor()
call is valid. That's not the case for orset(), but should be okay.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 16 Jun 2018 23:21:47 +0900 |
parents | b23ef2f06d98 |
children | 5d88fd1bc2af |
files | mercurial/revset.py |
diffstat | 1 files changed, 7 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revset.py Sat Jun 16 23:12:41 2018 +0900 +++ b/mercurial/revset.py Sat Jun 16 23:21:47 2018 +0900 @@ -203,6 +203,8 @@ def orset(repo, subset, x, order): xs = getlist(x) + if not xs: + return baseset() if order == followorder: # slow path to take the subset order return subset & _orsetlist(repo, fullreposet(repo), xs, anyorder) @@ -309,17 +311,12 @@ Will return empty list when passed no args. Greatest common ancestor of a single changeset is that changeset. """ - l = getlist(x) - rl = fullreposet(repo) anc = None - - # (getset(repo, rl, i) for i in l) generates a list of lists - for revs in (getset(repo, rl, i) for i in l): - for r in revs: - if anc is None: - anc = repo[r] - else: - anc = anc.ancestor(repo[r]) + for r in orset(repo, fullreposet(repo), x, order=anyorder): + if anc is None: + anc = repo[r] + else: + anc = anc.ancestor(repo[r]) if anc is not None and anc.rev() in subset: return baseset([anc.rev()])