bisect: calculate candidate set while finding children
authorMatt Mackall <mpm@selenic.com>
Mon, 31 Dec 2007 18:20:33 -0600
changeset 5769 49809f4a38d8
parent 5768 78d14403bdc7
child 5770 f5b858fc8067
bisect: calculate candidate set while finding children
hgext/hbisect.py
--- a/hgext/hbisect.py	Mon Dec 31 18:20:33 2007 -0600
+++ b/hgext/hbisect.py	Mon Dec 31 18:20:33 2007 -0600
@@ -34,9 +34,11 @@
     # build children dict
     children = {}
     visit = [badrev]
+    candidates = []
     while visit:
         rev = visit.pop(0)
         if ancestors[rev] == []:
+            candidates.append(rev)
             for prev in clparents(rev):
                 if prev != -1:
                     if prev in children:
@@ -45,8 +47,10 @@
                         children[prev] = [rev]
                         visit.append(prev)
 
+    candidates.sort()
+
     # accumulate ancestor lists
-    for rev in xrange(badrev + 1):
+    for rev in candidates:
         l = ancestors[rev]
         if l != None:
             if not l:
@@ -66,7 +70,6 @@
                     ancestors[c] = [a]
             ancestors[rev] = len(a)
 
-    candidates = a # ancestors of badrev, last rev visited
     del children
 
     if badrev not in candidates: