changeset 3512:630e0b216192

fix graph traversal in commands.bundle (it wasn't O(n))
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Wed, 25 Oct 2006 18:22:04 +0200
parents aa8f086cb141
children 9383af6f236d
files mercurial/commands.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Wed Oct 25 17:20:39 2006 +0200
+++ b/mercurial/commands.py	Wed Oct 25 18:22:04 2006 +0200
@@ -839,6 +839,7 @@
             visit = list(revs)
         else:
             visit = repo.changelog.heads()
+        seen = sets.Set(visit)
         while visit:
             n = visit.pop(0)
             parents = [p for p in repo.changelog.parents(n)
@@ -846,7 +847,10 @@
             if len(parents) == 0:
                 o.insert(0, n)
             else:
-                visit.extend(parents)
+                for p in parents:
+                    if p not in seen:
+                        seen.add(p)
+                        visit.append(p)
     else:
         setremoteconfig(ui, opts)
         dest = ui.expandpath(dest or 'default-push', dest or 'default')