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

login
register
mail settings
Submitter Yuya Nishihara
Date Dec. 6, 2017, 3:05 p.m.
Message ID <332685a30e1bc26b600c.1512572751@mimosa>
Download mbox | patch
Permalink /patch/25976/
State Accepted
Headers show

Comments

Yuya Nishihara - Dec. 6, 2017, 3:05 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.

Patch

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: