mercurial/dagop.py
changeset 35275 b4b328ea6175
parent 35274 2b348dc3239a
child 35276 205c3c6c1a51
--- a/mercurial/dagop.py	Thu Sep 22 18:11:37 2016 +0900
+++ b/mercurial/dagop.py	Thu Sep 22 18:18:56 2016 +0900
@@ -84,23 +84,20 @@
             visit[rev] = set()
         visit[rev].add(fctx)
 
-    c = fctx
     if followfirst:
         cut = 1
     else:
         cut = None
 
-    yield c
-    while True:
-        for parent in c.parents()[:cut]:
-            addvisit(parent)
-        if not visit:
-            break
+    addvisit(fctx)
+    while visit:
         rev = max(visit)
         c = visit[rev].pop()
         if not visit[rev]:
             del visit[rev]
         yield c
+        for parent in c.parents()[:cut]:
+            addvisit(parent)
 
 def _genrevancestors(repo, revs, followfirst, startdepth, stopdepth, cutfunc):
     if followfirst: