57
59
def test_push_to_checkout_updates_master(self):
58
60
"""Pushing into a checkout updates the checkout and the master branch"""
59
61
master_tree = self.make_branch_and_tree('master')
60
rev1 = master_tree.commit('master')
61
checkout = master_tree.branch.create_checkout('checkout')
62
checkout = self.make_branch_and_tree('checkout')
64
checkout.branch.bind(master_tree.branch)
65
except errors.UpgradeRequired:
66
# cant bind this format, the test is irrelevant.
68
rev1 = checkout.commit('master')
63
70
other = master_tree.branch.bzrdir.sprout('other').open_workingtree()
64
71
rev2 = other.commit('other commit')
77
89
# try to push, which should raise a BoundBranchConnectionFailure.
78
90
self.assertRaises(errors.BoundBranchConnectionFailure,
79
91
other.branch.push, checkout.branch)
94
class TestPushHook(TestCaseWithBranch):
98
TestCaseWithBranch.setUp(self)
100
def capture_post_push_hook(self, source, local, master, old_revno,
101
old_revid, new_revno, new_revid):
102
"""Capture post push hook calls to self.hook_calls.
104
The call is logged, as is some state of the two branches.
107
local_locked = local.is_locked()
108
local_base = local.base
112
self.hook_calls.append(
113
('post_push', source, local_base, master.base, old_revno, old_revid,
114
new_revno, new_revid, source.is_locked(), local_locked,
117
def test_post_push_empty_history(self):
118
target = self.make_branch('target')
119
source = self.make_branch('source')
120
Branch.hooks.install_hook('post_push', self.capture_post_push_hook)
122
# with nothing there we should still get a notification, and
123
# have both branches locked at the notification time.
125
('post_push', source, None, target.base, 0, NULL_REVISION,
126
0, NULL_REVISION, True, None, True)
130
def test_post_push_bound_branch(self):
131
# pushing to a bound branch should pass in the master branch to the
132
# hook, allowing the correct number of emails to be sent, while still
133
# allowing hooks that want to modify the target to do so to both
135
target = self.make_branch('target')
136
local = self.make_branch('local')
139
except errors.UpgradeRequired:
140
# cant bind this format, the test is irrelevant.
142
source = self.make_branch('source')
143
Branch.hooks.install_hook('post_push', self.capture_post_push_hook)
145
# with nothing there we should still get a notification, and
146
# have both branches locked at the notification time.
148
('post_push', source, local.base, target.base, 0, NULL_REVISION,
149
0, NULL_REVISION, True, True, True)
153
def test_post_push_nonempty_history(self):
154
target = self.make_branch_and_memory_tree('target')
157
rev1 = target.commit('rev 1')
159
sourcedir = target.bzrdir.clone(self.get_url('source'))
160
source = MemoryTree.create_on_branch(sourcedir.open_branch())
161
rev2 = source.commit('rev 2')
162
Branch.hooks.install_hook('post_push', self.capture_post_push_hook)
163
source.branch.push(target.branch)
164
# with nothing there we should still get a notification, and
165
# have both branches locked at the notification time.
167
('post_push', source.branch, None, target.branch.base, 1, rev1,
168
2, rev2, True, None, True)