39
39
self.assertEqual(source.bzrdir.root_transport.base, target.get_parent())
41
41
def test_sprout_uses_bzrdir_branch_format(self):
42
# branch.sprout(bzrdir) is defined as using the branch format selected
43
# by bzrdir; format preservation is achieved by parameterising the
44
# bzrdir during bzrdir.sprout, which is where stacking compatibility
45
# checks are done. So this test tests that each implementation of
46
# Branch.sprout delegates appropriately to the bzrdir which the
47
# branch is being created in, rather than testing that the result is
48
# in the format that we are testing (which is what would happen if
49
# the branch did not delegate appropriately).
42
50
if isinstance(self.branch_format, _mod_branch.BranchReferenceFormat):
43
51
raise tests.TestNotApplicable('cannot sprout to a reference')
44
52
# Start with a format that is unlikely to be the target format
53
# We call the super class to allow overriding the format of creation)
45
54
source = tests.TestCaseWithTransport.make_branch(self, 'old-branch',
46
55
format='metaweave')
47
56
target_bzrdir = self.make_bzrdir('target')
48
57
target_bzrdir.create_repository()
58
result_format = self.branch_format
59
if isinstance(target_bzrdir, remote.RemoteBzrDir):
60
# for a remote bzrdir, we need to parameterise it with a branch
61
# format, as, after creation, the newly opened remote objects
62
# do not have one unless a branch was created at the time.
63
# We use branch format 6 because its not the default, and its not
65
target_bzrdir._format.set_branch_format(_mod_branch.BzrBranchFormat6())
66
result_format = target_bzrdir._format.get_branch_format()
49
67
target = source.sprout(target_bzrdir)
51
self.assertIs(self.branch_format.__class__, target._format.__class__)
68
if isinstance(target, remote.RemoteBranch):
69
# we have to look at the real branch to see whether RemoteBranch
70
# did the right thing.
72
target = target._real_branch
73
self.assertIs(result_format.__class__, target._format.__class__)
53
75
def test_sprout_partial(self):
54
76
# test sprouting with a prefix of the revision-history.