Comment 3 for bug 393677

Revision history for this message
Robert Collins (lifeless) wrote : Re: pushing a 1.9 branch stacked on a 2a branch causes problems

=== modified file 'bzrlib/tests/blackbox/test_push.py'
--- bzrlib/tests/blackbox/test_push.py 2009-08-20 04:09:58 +0000
+++ bzrlib/tests/blackbox/test_push.py 2009-08-27 00:21:06 +0000
@@ -278,6 +278,20 @@
         b = branch.Branch.open(self.get_url('to'))
         self.assertEqual('../stack-on', b.get_stacked_on_url())

+ def test_push_smart_with_default_stacking_1_9_on_2a_bug_393677(self):
+ # If the default stacked-on location is a 2a format repo, and the
+ # branch being pushed has a 1.9 repository the result of pushing
+ # should be a clean error: The user has to upgrade to interoperate
+ # with that project anyway.
+ self.setup_smart_server_with_call_log()
+ self.make_branch('stack-on', format='2a')
+ self.make_bzrdir('.').get_config().set_default_stack_on('stack-on')
+ self.make_branch('from', format='1.9')
+ out, err = self.run_bzr_error([],
+ ['push', '-d', 'from', self.get_url('to')])
+ self.assertRaises(errors.NotBranchError, bzrdir.BzrDir.open,
+ self.get_url('to'))
+
     def create_simple_tree(self):
         tree = self.make_branch_and_tree('tree')
         self.build_tree(['tree/a'])

=== modified file 'bzrlib/tests/per_branch/test_create_clone.py'
--- bzrlib/tests/per_branch/test_create_clone.py 2009-08-20 04:09:58 +0000
+++ bzrlib/tests/per_branch/test_create_clone.py 2009-08-27 00:21:06 +0000
@@ -16,15 +16,40 @@

 """Tests for branch.create_clone behaviour."""

+from bzrlib import (
+ bzrdir,
+ errors,
+ remote,
+ tests,
+ )
 from bzrlib.branch import Branch
-from bzrlib import errors
-from bzrlib import remote
-from bzrlib import tests
 from bzrlib.tests.per_branch.test_branch import TestCaseWithBranch

 class TestCreateClone(TestCaseWithBranch):

+ def test_create_clone_on_transport_autostack_incompatible(self):
+ # Test that when we push somewhere with an autostack policy pointing
+ # at an incompatible branch we give an error cleanly and don't create
+ # the target.
+ tree = self.make_branch_and_tree('source')
+ revid = tree.commit('a commit')
+ # Create an incompatible format - rich roots we try to stack on
+ # 1.9, and non rich roots (like 1.9) we try to stack on 2a.
+ if tree.branch.repository.supports_rich_root():
+ trunk_format = "1.9"
+ else:
+ trunk_format = "2a"
+ target_transport = self.get_transport('target')
+ trunk = self.make_branch_and_tree(target_transport.base,
+ format=trunk_format)
+ source = tree.branch
+ self.assertRaises(errors.IncompatibleRepositories,
+ source.create_clone_on_transport, target_transport,
+ stacked_on=trunk.base)
+ self.assertRaises(errors.NotBranchError,
+ bzrdir.BzrDir.open_from_transport, target_transport)
+
     def test_create_clone_on_transport_missing_parent_dir(self):
         tree = self.make_branch_and_tree('source')
         tree.commit('a commit')