~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/branch_implementations/test_sprout.py

  • Committer: Andrew Bennetts
  • Date: 2008-11-14 03:47:37 UTC
  • mto: This revision was merged to the branch mainline in revision 3877.
  • Revision ID: andrew.bennetts@canonical.com-20081114034737-4dsajao903vu5qy7
Improve test_sprout.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""Tests for Branch.sprout()"""
18
18
 
19
19
from bzrlib import (
 
20
    branch as _mod_branch,
20
21
    remote,
21
22
    revision as _mod_revision,
22
23
    tests,
35
36
        target = source.bzrdir.sprout(self.get_url('target')).open_branch()
36
37
        self.assertEqual(source.bzrdir.root_transport.base, target.get_parent())
37
38
 
38
 
    def test_sprout_preserves_kind(self):
39
 
        branch1 = self.make_branch('branch1')
40
 
        target_repo = self.make_repository('branch2')
41
 
        target_repo.fetch(branch1.repository)
42
 
        branch2 = branch1.sprout(target_repo.bzrdir)
43
 
        if isinstance(branch1, remote.RemoteBranch):
44
 
            branch1._ensure_real()
45
 
            target_class = branch1._real_branch.__class__
46
 
        else:
47
 
            target_class = branch1.__class__
48
 
        self.assertIsInstance(branch2, target_class)
 
39
    def test_sprout_preserves_target_kind(self):
 
40
        if isinstance(self.branch_format, _mod_branch.BranchReferenceFormat):
 
41
            raise tests.TestNotApplicable('cannot sprout to a reference')
 
42
        # Start with a format that is unlikely to be the target format
 
43
        source = tests.TestCaseWithTransport.make_branch(self, 'old-branch',
 
44
                                                         format='metaweave')
 
45
        target_repo = self.make_repository('target', format=self.bzrdir_format)
 
46
        target_bzrdir = target_repo.bzrdir
 
47
        target = source.sprout(target_bzrdir)
 
48
 
 
49
        self.assertIs(self.branch_format.__class__, target._format.__class__)
49
50
 
50
51
    def test_sprout_partial(self):
51
52
        # test sprouting with a prefix of the revision-history.