77
79
# try to pull, which should raise a BoundBranchConnectionFailure.
78
80
self.assertRaises(errors.BoundBranchConnectionFailure,
79
81
checkout.branch.pull, other.branch)
84
class TestPullHook(TestCaseWithBranch):
88
TestCaseWithBranch.setUp(self)
90
def capture_post_pull_hook(self, source, local, master, old_revno,
91
old_revid, new_revno, new_revid):
92
"""Capture post pull hook calls to self.hook_calls.
94
The call is logged, as is some state of the two branches.
97
local_locked = local.is_locked()
98
local_base = local.base
102
self.hook_calls.append(
103
('post_pull', source, local_base, master.base, old_revno, old_revid,
104
new_revno, new_revid, source.is_locked(), local_locked,
107
def test_post_pull_empty_history(self):
108
target = self.make_branch('target')
109
source = self.make_branch('source')
110
Branch.hooks.install_hook('post_pull', self.capture_post_pull_hook)
112
# with nothing there we should still get a notification, and
113
# have both branches locked at the notification time.
115
('post_pull', source, None, target.base, 0, NULL_REVISION,
116
0, NULL_REVISION, True, None, True)
120
def test_post_pull_bound_branch(self):
121
# pulling to a bound branch should pass in the master branch to the
122
# hook, allowing the correct number of emails to be sent, while still
123
# allowing hooks that want to modify the target to do so to both
125
target = self.make_branch('target')
126
local = self.make_branch('local')
129
except errors.UpgradeRequired:
130
# cant bind this format, the test is irrelevant.
132
source = self.make_branch('source')
133
Branch.hooks.install_hook('post_pull', self.capture_post_pull_hook)
135
# with nothing there we should still get a notification, and
136
# have both branches locked at the notification time.
138
('post_pull', source, local.base, target.base, 0, NULL_REVISION,
139
0, NULL_REVISION, True, True, True)
143
def test_post_pull_nonempty_history(self):
144
target = self.make_branch_and_memory_tree('target')
147
rev1 = target.commit('rev 1')
149
sourcedir = target.bzrdir.clone(self.get_url('source'))
150
source = MemoryTree.create_on_branch(sourcedir.open_branch())
151
rev2 = source.commit('rev 2')
152
Branch.hooks.install_hook('post_pull', self.capture_post_pull_hook)
153
target.branch.pull(source.branch)
154
# with nothing there we should still get a notification, and
155
# have both branches locked at the notification time.
157
('post_pull', source.branch, None, target.branch.base, 1, rev1,
158
2, rev2, True, None, True)