17
17
"""Tests for branch.create_clone behaviour."""
19
from bzrlib.branch import Branch
19
20
from bzrlib.tests.branch_implementations.test_branch import TestCaseWithBranch
21
from bzrlib import remote
22
24
class TestCreateClone(TestCaseWithBranch):
54
56
stacked_on=trunk.base)
55
57
self.assertEqual(revid, result.last_revision())
56
58
self.assertEqual(trunk.base, result.get_stacked_on_url())
60
def assertBranchHookBranchIsStacked(self, pre_change_params):
61
# Just calling will either succeed or fail.
62
pre_change_params.branch.get_stacked_on_url()
63
self.hook_calls.append(pre_change_params)
65
def test_create_clone_on_transport_stacked_hooks_get_stacked_branch(self):
66
tree = self.make_branch_and_tree('source')
67
tree.commit('a commit')
68
trunk = tree.branch.create_clone_on_transport(
69
self.get_transport('trunk'))
70
revid = tree.commit('a second commit')
72
target_transport = self.get_transport('target')
74
Branch.hooks.install_named_hook("pre_change_branch_tip",
75
self.assertBranchHookBranchIsStacked, None)
76
result = tree.branch.create_clone_on_transport(target_transport,
77
stacked_on=trunk.base)
78
self.assertEqual(revid, result.last_revision())
79
self.assertEqual(trunk.base, result.get_stacked_on_url())
80
# Smart servers invoke hooks on both sides
81
if isinstance(result, remote.RemoteBranch):
85
self.assertEqual(expected_calls, len(self.hook_calls))