54
58
stacked_on=trunk.base)
55
59
self.assertEqual(revid, result.last_revision())
56
60
self.assertEqual(trunk.base, result.get_stacked_on_url())
62
def test_create_clone_of_multiple_roots(self):
64
builder = self.make_branch_builder('local')
65
except (errors.TransportNotPossible, errors.UninitializableFormat):
66
raise tests.TestNotApplicable('format not directly constructable')
67
builder.start_series()
68
builder.build_snapshot('rev1', None, [
69
('add', ('', 'root-id', 'directory', ''))])
70
builder.build_snapshot('rev2', ['rev1'], [])
71
builder.build_snapshot('other', None, [
72
('add', ('', 'root-id', 'directory', ''))])
73
builder.build_snapshot('rev3', ['rev2', 'other'], [])
74
builder.finish_series()
75
local = builder.get_branch()
76
local.bzrdir.clone(self.get_url('remote'), revision_id='rev3')
78
def assertBranchHookBranchIsStacked(self, pre_change_params):
79
# Just calling will either succeed or fail.
80
pre_change_params.branch.get_stacked_on_url()
81
self.hook_calls.append(pre_change_params)
83
def test_create_clone_on_transport_stacked_hooks_get_stacked_branch(self):
84
tree = self.make_branch_and_tree('source')
85
tree.commit('a commit')
86
trunk = tree.branch.create_clone_on_transport(
87
self.get_transport('trunk'))
88
revid = tree.commit('a second commit')
90
target_transport = self.get_transport('target')
92
Branch.hooks.install_named_hook("pre_change_branch_tip",
93
self.assertBranchHookBranchIsStacked, None)
94
result = tree.branch.create_clone_on_transport(target_transport,
95
stacked_on=trunk.base)
96
self.assertEqual(revid, result.last_revision())
97
self.assertEqual(trunk.base, result.get_stacked_on_url())
98
# Smart servers invoke hooks on both sides
99
if isinstance(result, remote.RemoteBranch):
103
self.assertEqual(expected_calls, len(self.hook_calls))