Raise error when trying to change repository root, add test for bug 118787.
authorJelmer Vernooij <jelmer@samba.org>
Sat, 20 Oct 2007 19:20:18 +0000 (21:20 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Sat, 20 Oct 2007 19:20:18 +0000 (21:20 +0200)
commit.py
tests/test_push.py

index be9860b4e6d4782c1866e70112302137dcc949ab..1243d5ce1c125d94c2d34771b318d5d089928c1a 100644 (file)
--- a/commit.py
+++ b/commit.py
@@ -20,7 +20,8 @@ from svn.core import Pool, SubversionException
 
 from bzrlib import debug, osutils, urlutils
 from bzrlib.branch import Branch
-from bzrlib.errors import InvalidRevisionId, DivergedBranches, UnrelatedBranches
+from bzrlib.errors import (BzrError, InvalidRevisionId, DivergedBranches, 
+                           UnrelatedBranches)
 from bzrlib.inventory import Inventory
 from bzrlib.repository import RootCommitBuilder, InterRepository
 from bzrlib.revision import NULL_REVISION
@@ -397,6 +398,8 @@ class SvnCommitBuilder(RootCommitBuilder):
             # Already exists, old copy needs to be removed
             name = "/".join(elements)
             if replace_existing:
+                if name == "":
+                    raise BzrError("changing lhs branch history not possible on repository root")
                 self.mutter("removing branch dir %r" % name)
                 self.editor.delete_entry(name, -1, ret[-1])
             if base_path is not None:
index 9dbd389049e05b4438b52319cd7de396bbf53bda..1666d1b0b8e147d284f01227730192f93742418e 100644 (file)
@@ -21,7 +21,7 @@ from bzrlib.inventory import Inventory
 from bzrlib.merge import Merger, Merge3Merger
 from bzrlib.progress import DummyProgress
 from bzrlib.repository import Repository
-from bzrlib.tests import TestCaseWithTransport
+from bzrlib.tests import KnownFailure, TestCaseWithTransport
 from bzrlib.trace import mutter
 from bzrlib.workingtree import WorkingTree
 
@@ -352,6 +352,7 @@ class PushNewBranchTests(TestCaseWithSubversionRepository):
         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"))
+        raise KnownFailure("can't work for repository root")
         wt.branch.push(Branch.open(repos_url))
 
     def test_push_replace_existing_branch(self):
@@ -446,6 +447,37 @@ class PushNewBranchTests(TestCaseWithSubversionRepository):
             svnrepos.generate_revision_id(1, "trunk", "trunk0") 
             , revid1, revid2], newbranch.revision_history())
 
+    def test_push_overwrite(self):
+        repos_url = self.make_client("a", "dc")
+        self.build_tree({'dc/trunk/bloe': "text"})
+        self.client_add("dc/trunk")
+        self.client_commit("dc", "initial")
+
+        os.mkdir("d1")
+        bzrdir = BzrDir.open(repos_url+"/trunk").sprout("d1")
+        bzrwt1 = bzrdir.open_workingtree()
+
+        os.mkdir("d2")
+        bzrdir = BzrDir.open(repos_url+"/trunk").sprout("d2")
+        bzrwt2 = bzrdir.open_workingtree()
+
+        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 = bzrwt1.commit("Do a commit")
+
+        bzrwt1.branch.push(Branch.open(repos_url+"/trunk"))
+
+        raise KnownFailure("push --overwrite not supported yet")
+
+        bzrwt2.branch.push(Branch.open(repos_url+"/trunk"), overwrite=True)
+
+        self.assertEquals([revid2], 
+                Branch.open(repos_url+"/trunk").revision_history())
+
     def test_complex_rename(self):
         repos_url = self.make_client("a", "dc")
         bzrwt = BzrDir.create_standalone_workingtree("c",