revset: return early when revs is empty
authorMartin von Zweigbergk <martinvonz@google.com>
Wed, 06 May 2015 11:29:09 -0700
changeset 24938 6db8074f9150
parent 24937 f5518b47cdd1
child 24939 85544a52ee84
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.
mercurial/revset.py
--- 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)