/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

1st cut merge of bzr.dev r3907

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tests for Branch.sprout()"""
18
18
 
 
19
import os
19
20
from bzrlib import (
 
21
    branch as _mod_branch,
20
22
    remote,
21
23
    revision as _mod_revision,
22
24
    tests,
23
25
    )
 
26
from bzrlib.tests import KnownFailure, SymlinkFeature, UnicodeFilenameFeature
24
27
from bzrlib.tests.branch_implementations import TestCaseWithBranch
25
28
 
26
29
 
35
38
        target = source.bzrdir.sprout(self.get_url('target')).open_branch()
36
39
        self.assertEqual(source.bzrdir.root_transport.base, target.get_parent())
37
40
 
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)
 
41
    def test_sprout_uses_bzrdir_branch_format(self):
 
42
        if isinstance(self.branch_format, _mod_branch.BranchReferenceFormat):
 
43
            raise tests.TestNotApplicable('cannot sprout to a reference')
 
44
        # Start with a format that is unlikely to be the target format
 
45
        source = tests.TestCaseWithTransport.make_branch(self, 'old-branch',
 
46
                                                         format='metaweave')
 
47
        target_bzrdir = self.make_bzrdir('target')
 
48
        target_bzrdir.create_repository()
 
49
        target = source.sprout(target_bzrdir)
 
50
 
 
51
        self.assertIs(self.branch_format.__class__, target._format.__class__)
49
52
 
50
53
    def test_sprout_partial(self):
51
54
        # test sprouting with a prefix of the revision-history.
97
100
            revision_id='rev1a').open_workingtree()
98
101
        self.assertEqual('rev1a', wt2.last_revision())
99
102
        self.failUnlessExists('target/a')
 
103
 
 
104
    def test_sprout_with_unicode_symlink(self):
 
105
        # this tests bug #272444
 
106
        # Since the trigger function seems to be set_parent_trees, there exists
 
107
        # also a similar test, with name test_unicode_symlink, in class
 
108
        # TestSetParents at file workingtree_implementations/test_parents.py
 
109
        self.requireFeature(SymlinkFeature)
 
110
        self.requireFeature(UnicodeFilenameFeature)
 
111
 
 
112
        tree = self.make_branch_and_tree('tree1')
 
113
 
 
114
        # The link points to a file whose name is an omega
 
115
        # U+03A9 GREEK CAPITAL LETTER OMEGA
 
116
        # UTF-8: ce a9  UTF-16BE: 03a9  Decimal: Ω
 
117
        os.symlink(u'\u03a9','tree1/link_name')
 
118
        tree.add(['link_name'],['link-id'])
 
119
 
 
120
        try:
 
121
            # python 2.7a0 failed on commit:
 
122
            revision = tree.commit('added a link to a Unicode target')
 
123
            # python 2.5 failed on sprout:
 
124
            tree.bzrdir.sprout('target')
 
125
        except UnicodeEncodeError, e:
 
126
            raise KnownFailure('there is no support for'
 
127
                               ' symlinks to non-ASCII targets (bug #272444)')
 
128