Add another test for #145148
authorJelmer Vernooij <jelmer@samba.org>
Sat, 20 Oct 2007 18:10:41 +0000 (20:10 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Sat, 20 Oct 2007 18:10:41 +0000 (20:10 +0200)
commit.py
tests/test_push.py

index 7cca5e04a41bdc383682732c99d6798d10016659..be9860b4e6d4782c1866e70112302137dcc949ab 100644 (file)
--- a/commit.py
+++ b/commit.py
@@ -88,6 +88,7 @@ class SvnCommitBuilder(RootCommitBuilder):
             self.base_revid = None
         else:
             self.base_revid = parents[0]
+
         self.base_revno = self.branch.revision_id_to_revno(self.base_revid)
         if self.base_revid is None:
             self.base_revnum = -1
@@ -442,7 +443,6 @@ class SvnCommitBuilder(RootCommitBuilder):
             # See whether the base of the commit matches the lhs parent
             # if not, we need to replace the existing directory
             if len(bp_parts) == len(existing_bp_parts):
-
                 if self.base_path.strip("/") != "/".join(bp_parts).strip("/"):
                     replace_existing = True
                 elif self.base_revnum < self.repository._log.find_latest_change(self.branch.get_branch_path(), repository_latest_revnum, include_children=True):
@@ -450,7 +450,7 @@ class SvnCommitBuilder(RootCommitBuilder):
 
             # TODO: Accept create_prefix argument (#118787)
             branch_batons = self.open_branch_batons(root, bp_parts,
-                existing_bp_parts, self.base_path, self.base_revnum,
+                existing_bp_parts, self.base_path, self.base_revnum, 
                 replace_existing)
 
             # Make sure the root id is stored properly
index 62f149579119244694f85c80612121f61e4535e4..9dbd389049e05b4438b52319cd7de396bbf53bda 100644 (file)
@@ -307,14 +307,16 @@ class PushNewBranchTests(TestCaseWithSubversionRepository):
         self.assertEquals(revid, newbranch.last_revision())
         self.assertEquals([revid], newbranch.revision_history())
 
-    def test_push_replace_existing(self):
-        # svn-1
-        # |
-        # bzr-1
-        # |    \
-        # bzr2 svn2
-        # |    /
-        # merge
+    # revision graph for the two tests below:
+    # svn-1
+    # |
+    # base
+    # |    \
+    # diver svn2
+    # |    /
+    # merge
+
+    def test_push_replace_existing_root(self):
         repos_url = self.make_client("test", "svnco")
         self.build_tree({'svnco/foo.txt': 'foo'})
         self.client_add("svnco/foo.txt")
@@ -326,7 +328,7 @@ class PushNewBranchTests(TestCaseWithSubversionRepository):
         wt = dir.open_workingtree()
         self.build_tree({'bzrco/bar.txt': 'bar'})
         wt.add("bar.txt")
-        base_revid = wt.commit("add another file")
+        base_revid = wt.commit("add another file", rev_id="mybase")
         wt.branch.push(Branch.open(repos_url))
 
         self.build_tree({"svnco/baz.txt": "baz"})
@@ -337,7 +339,7 @@ class PushNewBranchTests(TestCaseWithSubversionRepository):
 
         self.build_tree({"bzrco/qux.txt": "qux"})
         wt.add("qux.txt")
-        wt.commit("add still more files")
+        wt.commit("add still more files", rev_id="mydiver")
 
         repos = Repository.open(repos_url)
         wt.branch.repository.fetch(repos)
@@ -348,10 +350,50 @@ class PushNewBranchTests(TestCaseWithSubversionRepository):
         self.assertEquals(base_revid, merge.base_rev_id)
         merge.set_pending()
         self.assertEquals([wt.last_revision(), other_rev], wt.get_parent_ids())
-        wt.commit("merge")
+        wt.commit("merge", rev_id="mymerge")
         self.assertTrue(os.path.exists("bzrco/baz.txt"))
         wt.branch.push(Branch.open(repos_url))
 
+    def test_push_replace_existing_branch(self):
+        repos_url = self.make_client("test", "svnco")
+        self.build_tree({'svnco/trunk/foo.txt': 'foo'})
+        self.client_add("svnco/trunk")
+        self.client_commit("svnco", "add file") #1
+        self.client_update("svnco")
+
+        os.mkdir('bzrco')
+        dir = BzrDir.open(repos_url+"/trunk").sprout("bzrco")
+        wt = dir.open_workingtree()
+        self.build_tree({'bzrco/bar.txt': 'bar'})
+        wt.add("bar.txt")
+        base_revid = wt.commit("add another file", rev_id="mybase")
+        wt.branch.push(Branch.open(repos_url+"/trunk"))
+
+        self.build_tree({"svnco/trunk/baz.txt": "baz"})
+        self.client_add("svnco/trunk/baz.txt")
+        self.assertEquals(3, 
+                self.client_commit("svnco", "add yet another file")[0])
+        self.client_update("svnco")
+
+        self.build_tree({"bzrco/qux.txt": "qux"})
+        wt.add("qux.txt")
+        wt.commit("add still more files", rev_id="mydiver")
+
+        repos = Repository.open(repos_url)
+        wt.branch.repository.fetch(repos)
+        other_rev = repos.generate_revision_id(3, "trunk", "trunk0")
+        merge = Merger.from_revision_ids(DummyProgress(), wt, other=other_rev)
+        merge.merge_type = Merge3Merger
+        merge.do_merge()
+        self.assertEquals(base_revid, merge.base_rev_id)
+        merge.set_pending()
+        self.assertEquals([wt.last_revision(), other_rev], wt.get_parent_ids())
+        wt.commit("merge", rev_id="mymerge")
+        self.assertTrue(os.path.exists("bzrco/baz.txt"))
+        wt.branch.push(Branch.open(repos_url+"/trunk"))
+
+
+
     def test_repeat(self):
         repos_url = self.make_client("a", "dc")
         bzrwt = BzrDir.create_standalone_workingtree("c",