/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

merge bzr.dev r4154

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import os
20
20
from bzrlib import (
21
21
    branch as _mod_branch,
 
22
    errors,
22
23
    remote,
23
24
    revision as _mod_revision,
24
25
    tests,
25
26
    )
26
 
from bzrlib.tests import KnownFailure, SymlinkFeature, UnicodeFilenameFeature
27
27
from bzrlib.tests.branch_implementations import TestCaseWithBranch
28
28
 
29
29
 
131
131
        # Since the trigger function seems to be set_parent_trees, there exists
132
132
        # also a similar test, with name test_unicode_symlink, in class
133
133
        # TestSetParents at file workingtree_implementations/test_parents.py
134
 
        self.requireFeature(SymlinkFeature)
135
 
        self.requireFeature(UnicodeFilenameFeature)
 
134
        self.requireFeature(tests.SymlinkFeature)
 
135
        self.requireFeature(tests.UnicodeFilenameFeature)
136
136
 
137
137
        tree = self.make_branch_and_tree('tree1')
138
138
 
142
142
        os.symlink(u'\u03a9','tree1/link_name')
143
143
        tree.add(['link_name'],['link-id'])
144
144
 
 
145
        revision = tree.commit('added a link to a Unicode target')
 
146
        tree.bzrdir.sprout('target')
 
147
 
 
148
    def assertBranchHookBranchIsStacked(self, pre_change_params):
 
149
        # Just calling will either succeed or fail.
 
150
        pre_change_params.branch.get_stacked_on_url()
 
151
        self.hook_calls.append(pre_change_params)
 
152
 
 
153
    def test_sprout_stacked_hooks_get_stacked_branch(self):
 
154
        tree = self.make_branch_and_tree('source')
 
155
        tree.commit('a commit')
 
156
        revid = tree.commit('a second commit')
 
157
        source = tree.branch
 
158
        target_transport = self.get_transport('target')
 
159
        self.hook_calls = []
 
160
        _mod_branch.Branch.hooks.install_named_hook("pre_change_branch_tip",
 
161
            self.assertBranchHookBranchIsStacked, None)
145
162
        try:
146
 
            # python 2.7a0 failed on commit:
147
 
            revision = tree.commit('added a link to a Unicode target')
148
 
            # python 2.5 failed on sprout:
149
 
            tree.bzrdir.sprout('target')
150
 
        except UnicodeEncodeError, e:
151
 
            raise KnownFailure('there is no support for'
152
 
                               ' symlinks to non-ASCII targets (bug #272444)')
 
163
            dir = source.bzrdir.sprout(target_transport.base,
 
164
                source.last_revision(), possible_transports=[target_transport],
 
165
                source_branch=source, stacked=True)
 
166
        except errors.UnstackableBranchFormat:
 
167
            if isinstance(self.branch_format, _mod_branch.BzrBranchFormat4):
 
168
                raise tests.KnownFailure(
 
169
                    "Format 4 doesn't auto stack successfully.")
 
170
            else:
 
171
                raise
 
172
        result = dir.open_branch()
 
173
        self.assertEqual(revid, result.last_revision())
 
174
        self.assertEqual(source.base, result.get_stacked_on_url())
 
175
        # Smart servers invoke hooks on both sides
 
176
        if isinstance(result, remote.RemoteBranch):
 
177
            expected_calls = 2
 
178
        else:
 
179
            expected_calls = 1
 
180
        self.assertEqual(expected_calls, len(self.hook_calls))
153
181