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.
--- a/mercurial/revset.py Wed Mar 26 16:14:30 2014 -0700
+++ b/mercurial/revset.py Wed May 06 11:29:09 2015 -0700
@@ -25,20 +25,20 @@
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)