changeset 3318: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 0b5d626b354e
children 80654c248793
files mercurial/commands.py tests/test-bundle-r tests/test-bundle-r.out
diffstat 3 files changed, 64 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Sat Oct 07 15:16:47 2006 -0400
+++ b/mercurial/commands.py	Mon Oct 09 15:44:20 2006 +0200
@@ -789,16 +789,25 @@
         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')
--- a/tests/test-bundle-r	Sat Oct 07 15:16:47 2006 -0400
+++ b/tests/test-bundle-r	Mon Oct 09 15:44:20 2006 +0200
@@ -72,7 +72,8 @@
 hg -R test bundle --base 2 -r 7 test-bundle-branch2.hg
 hg -R test bundle --base 2 test-bundle-all.hg
 hg -R test bundle --base 3 -r tip test-bundle-should-fail.hg
-cd test-2
+hg clone test-2 test-9
+cd test-9
 echo % 2
 hg tip -q
 hg unbundle ../test-bundle-should-fail.hg
@@ -81,13 +82,28 @@
 hg unbundle ../test-bundle-all.hg
 echo % 8
 hg tip -q
+hg verify
 hg rollback
 echo % 2
 hg tip -q
 hg unbundle ../test-bundle-branch1.hg
 echo % 4
 hg tip -q
+hg verify
+hg rollback
 hg unbundle ../test-bundle-branch2.hg
-echo % 8
+echo % 6
 hg tip -q
 hg verify
+
+cd ../test
+hg merge 7
+hg ci -m merge -d "1000000 0"
+cd ..
+hg -R test bundle --base 2 test-bundle-head.hg
+hg clone test-2 test-10
+cd test-10
+hg unbundle ../test-bundle-head.hg
+echo % 9
+hg tip -q
+hg verify
--- a/tests/test-bundle-r.out	Sat Oct 07 15:16:47 2006 -0400
+++ b/tests/test-bundle-r.out	Mon Oct 09 15:44:20 2006 +0200
@@ -148,6 +148,7 @@
 % should fail
 abort: --base is incompatible with specifiying a destination
 abort: repository default-push not found!
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 % 2
 2:d62976ca1e50
 adding changesets
@@ -163,6 +164,11 @@
 (run 'hg heads' to see heads, 'hg merge' to merge)
 % 8
 8:836ac62537ab
+checking changesets
+checking manifests
+crosschecking files in changesets and manifests
+checking files
+4 files, 9 changesets, 7 total revisions
 rolling back last transaction
 % 2
 2:d62976ca1e50
@@ -173,15 +179,36 @@
 (run 'hg update' to get a working copy)
 % 4
 4:836ac62537ab
+checking changesets
+checking manifests
+crosschecking files in changesets and manifests
+checking files
+2 files, 5 changesets, 5 total revisions
+rolling back last transaction
 adding changesets
 adding manifests
 adding file changes
-added 4 changesets with 2 changes to 3 files (+1 heads)
+added 4 changesets with 3 changes to 3 files (+1 heads)
 (run 'hg heads' to see heads, 'hg merge' to merge)
-% 8
-8:80fe151401c2
+% 6
+6:80fe151401c2
 checking changesets
 checking manifests
 crosschecking files in changesets and manifests
 checking files
-4 files, 9 changesets, 7 total revisions
+3 files, 7 changesets, 6 total revisions
+2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+(branch merge, don't forget to commit)
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+adding changesets
+adding manifests
+adding file changes
+added 7 changesets with 4 changes to 4 files
+(run 'hg update' to get a working copy)
+% 9
+9:607fe5912aad
+checking changesets
+checking manifests
+crosschecking files in changesets and manifests
+checking files
+4 files, 10 changesets, 7 total revisions