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)
137
137
tree = self.make_branch_and_tree('tree1')
142
142
os.symlink(u'\u03a9','tree1/link_name')
143
143
tree.add(['link_name'],['link-id'])
145
revision = tree.commit('added a link to a Unicode target')
146
tree.bzrdir.sprout('target')
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)
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')
158
target_transport = self.get_transport('target')
160
_mod_branch.Branch.hooks.install_named_hook("pre_change_branch_tip",
161
self.assertBranchHookBranchIsStacked, None)
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.")
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):
180
self.assertEqual(expected_calls, len(self.hook_calls))