# HG changeset patch # User Martin von Zweigbergk # Date 2015-05-06 18:29:09 # Node ID 6db8074f9150a5152375eef6b2a82774c6d991d7 # Parent f5518b47cdd19a76598a68790bd591e80a70c3d6 revset: return early when revs is empty By introducing an early return in _revancestors() when revs is empty, we make it so inputrev is never None, which simplifies the subsequent code. diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -25,20 +25,20 @@ def _revancestors(repo, revs, followfirs cl = repo.changelog def iterate(): - revqueue, inputrev = None, None - h = [] - revs.sort(reverse=True) revqueue = util.deque(revs) - if revqueue: - inputrev = revqueue.popleft() - heapq.heappush(h, -inputrev) + if not revqueue: + return + + h = [] + inputrev = revqueue.popleft() + heapq.heappush(h, -inputrev) seen = set() while h: current = -heapq.heappop(h) if current not in seen: - if inputrev and current == inputrev: + if current == inputrev: if revqueue: inputrev = revqueue.popleft() heapq.heappush(h, -inputrev)