[PATCH 7 of 8] dagop: put start fctx into visit dict of filectxancestors()

Yuya Nishihara yuya at tcha.org
Wed Dec 6 10:05:51 EST 2017


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1474535936 -32400
#      Thu Sep 22 18:18:56 2016 +0900
# Node ID 332685a30e1bc26b600c8d446820e87536c59c00
# Parent  e1a0780894ccd68c5a6c09e7d61401bd0d37c73f
dagop: put start fctx into visit dict of filectxancestors()

Prepares for multiple start revisions/files.

diff --git a/mercurial/dagop.py b/mercurial/dagop.py
--- a/mercurial/dagop.py
+++ b/mercurial/dagop.py
@@ -84,23 +84,20 @@ def filectxancestors(fctx, followfirst=F
             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:


More information about the Mercurial-devel mailing list