Rev 1537: Support overwriting unrelated branches. in http://people.samba.org/bzr/jelmer/bzr-svn/trunk
Jelmer Vernooij
jelmer at samba.org
Sat Aug 2 22:53:03 BST 2008
At http://people.samba.org/bzr/jelmer/bzr-svn/trunk
------------------------------------------------------------
revno: 1537
revision-id: jelmer at samba.org-20080802215302-7yjst03v4xdn4d3d
parent: jelmer at samba.org-20080802213849-ek8i3wuewwon5d4a
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Sat 2008-08-02 23:53:02 +0200
message:
Support overwriting unrelated branches.
modified:
branch.py svnbranch.py-20051017135706-11c749eb0dab04a7
commit.py commit.py-20060607190346-qvq128wgfubhhgm2-1
tests/test_push.py test_push.py-20070201165715-g2ievcdfqi33wqsy-1
=== modified file 'branch.py'
--- a/branch.py 2008-08-02 21:38:49 +0000
+++ b/branch.py 2008-08-02 21:53:02 +0000
@@ -353,11 +353,12 @@
missing.append(revid)
return None
- def otherline_missing_revisions(self, other, stop_revision):
+ def otherline_missing_revisions(self, other, stop_revision, overwrite=False):
"""Find the revisions missing on the mainline.
:param other: Other branch to retrieve revisions from.
:param stop_revision: Revision to stop fetching at.
+ :param overwrite: Whether or not the existing data should be overwritten
"""
missing = []
for revid in other.repository.iter_reverse_revision_history(stop_revision):
@@ -365,7 +366,10 @@
missing.reverse()
return missing
missing.append(revid)
- return None
+ if not overwrite:
+ return None
+ else:
+ return missing
def last_revision_info(self):
"""See Branch.last_revision_info()."""
@@ -493,7 +497,7 @@
todo = self.mainline_missing_revisions(other, stop_revision)
if todo is None:
# Not possible to add cleanly onto mainline, perhaps need a replace operation
- todo = self.otherline_missing_revisions(other, stop_revision)
+ todo = self.otherline_missing_revisions(other, stop_revision, overwrite)
if todo is None:
raise DivergedBranches(self, other)
=== modified file 'commit.py'
--- a/commit.py 2008-07-06 13:26:14 +0000
+++ b/commit.py 2008-08-02 21:53:02 +0000
@@ -505,7 +505,7 @@
# 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("/"):
+ if self.base_path is None or 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):
replace_existing = True
=== modified file 'tests/test_push.py'
--- a/tests/test_push.py 2008-08-02 21:38:49 +0000
+++ b/tests/test_push.py 2008-08-02 21:53:02 +0000
@@ -703,6 +703,40 @@
self.assertEquals(bzrwt2.branch.revision_history(),
Branch.open(repos_url+"/trunk").revision_history())
+ def test_push_overwrite_unrelated(self):
+ repos_url = self.make_repository("a")
+
+ dc = self.get_commit_editor(repos_url)
+ trunk = dc.add_dir("trunk")
+ trunk.add_file("trunk/bloe").modify("text")
+ dc.close()
+
+ os.mkdir("d1")
+ bzrdir = BzrDir.open(repos_url+"/trunk").sprout("d1")
+ bzrwt1 = bzrdir.open_workingtree()
+
+ bzrwt2 = BzrDir.create_standalone_workingtree("d2",
+ format=format.get_rich_root_format())
+
+ self.build_tree({'d1/myfile': "Tour"})
+ bzrwt1.add("myfile")
+ revid1 = bzrwt1.commit("Do a commit")
+
+ self.build_tree({'d2/myfile': "France"})
+ bzrwt2.add("myfile")
+ revid2 = bzrwt2.commit("Do a commit")
+
+ bzrwt1.branch.push(Branch.open(repos_url+"/trunk"))
+ self.assertEquals(bzrwt1.branch.revision_history(),
+ Branch.open(repos_url+"/trunk").revision_history())
+
+ bzrwt2.branch.push(Branch.open(repos_url+"/trunk"), overwrite=True)
+
+ self.assertEquals(bzrwt2.branch.revision_history(),
+ Branch.open(repos_url+"/trunk").revision_history())
+
+
+
def test_complex_rename(self):
repos_url = self.make_repository("a")
bzrwt = BzrDir.create_standalone_workingtree("c",
More information about the bazaar-commits
mailing list