findincoming: do the binary search in branches in parallel
authorBenoit Boissinot <benoit.boissinot@ens-lyon.org>
Wed, 22 Oct 2008 21:43:35 +0200
changeset 7208 acb87c5b4aeb
parent 7207 fe0a4ed4634f
child 7209 65f14ca8d2eb
findincoming: do the binary search in branches in parallel
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Wed Oct 22 21:41:57 2008 +0200
+++ b/mercurial/localrepo.py	Wed Oct 22 21:43:35 2008 +0200
@@ -1343,27 +1343,29 @@
                         unknown.append(b)
 
         # do binary search on the branches we found
+        search = [(t, b) for (t, b, p1, p2) in search]
         while search:
-            n = search.pop(0)
+            newsearch = []
             reqcnt += 1
-            l = remote.between([(n[0], n[1])])[0]
-            l.append(n[1])
-            p = n[0]
-            f = 1
-            for i in l:
-                self.ui.debug(_("narrowing %d:%d %s\n") % (f, len(l), short(i)))
-                if i in m:
-                    if f <= 2:
-                        self.ui.debug(_("found new branch changeset %s\n") %
-                                          short(p))
-                        fetch[p] = 1
-                        base[i] = 1
-                    else:
-                        self.ui.debug(_("narrowed branch search to %s:%s\n")
-                                      % (short(p), short(i)))
-                        search.append((p, i))
-                    break
-                p, f = i, f * 2
+            for n, l in zip(search, remote.between(search)):
+                l.append(n[1])
+                p = n[0]
+                f = 1
+                for i in l:
+                    self.ui.debug(_("narrowing %d:%d %s\n") % (f, len(l), short(i)))
+                    if i in m:
+                        if f <= 2:
+                            self.ui.debug(_("found new branch changeset %s\n") %
+                                              short(p))
+                            fetch[p] = 1
+                            base[i] = 1
+                        else:
+                            self.ui.debug(_("narrowed branch search to %s:%s\n")
+                                          % (short(p), short(i)))
+                            newsearch.append((p, i))
+                        break
+                    p, f = i, f * 2
+                search = newsearch
 
         # sanity check our fetch list
         for f in fetch.keys():