diff mercurial/commands.py @ 3293:a225055b3b59

bundle --base: use the right set for the base
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Mon, 09 Oct 2006 15:44:20 +0200
parents d89e98840b08
children 80654c248793
line wrap: on
line diff
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -789,16 +789,25 @@ def bundle(ui, repo, fname, dest=None, *
         if dest:
             raise util.Abort(_("--base is incompatible with specifiying "
                                "a destination"))
+        base = [repo.lookup(rev) for rev in base]
+        # create the right base
+        # XXX: nodesbetween / changegroup* should be "fixed" instead
         o = []
+        has_set = sets.Set(base)
         for n in base:
-            o.extend(repo.changelog.children(repo.lookup(n)))
-        # add common ancestor
+            has_set.update(repo.changelog.reachable(n))
         if revs:
-            all = o + revs
+            visit = list(revs)
         else:
-            all = o + repo.changelog.heads()
-        ancestor = reduce(lambda a, b: repo.changelog.ancestor(a, b), all)
-        o.append(ancestor)
+            visit = repo.changelog.heads()
+        while visit:
+            n = visit.pop(0)
+            parents = [p for p in repo.changelog.parents(n)
+                       if p != nullid and p not in has_set]
+            if len(parents) == 0:
+                o.insert(0, n)
+            else:
+                visit.extend(parents)
     else:
         setremoteconfig(ui, opts)
         dest = ui.expandpath(dest or 'default-push', dest or 'default')