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
# 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):
# 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
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")
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"})
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)
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",