36
36
other.commit('my change', rev_id='M1', allow_pointless=True)
37
37
mine.merge_from_branch(other.branch)
38
38
mine.commit('merge my change', rev_id='P2')
39
mine.branch.push(other.branch)
39
result = mine.branch.push(other.branch)
40
40
self.assertEqual(['P1', 'P2'], other.branch.revision_history())
41
# result object contains some structured data
42
self.assertEqual(result.old_revid, 'M1')
43
self.assertEqual(result.new_revid, 'P2')
44
# and it can be treated as an integer for compatibility
45
self.assertEqual(int(result), 0)
42
47
def test_push_merged_indirect(self):
43
48
# it should be possible to do a push from one branch into another
143
148
self.hook_calls = []
144
149
TestCaseWithBranch.setUp(self)
146
def capture_post_push_hook(self, source, local, master, old_revno,
147
old_revid, new_revno, new_revid):
151
def capture_post_push_hook(self, result):
148
152
"""Capture post push hook calls to self.hook_calls.
150
154
The call is logged, as is some state of the two branches.
153
local_locked = local.is_locked()
154
local_base = local.base
156
if result.local_branch:
157
local_locked = result.local_branch.is_locked()
158
local_base = result.local_branch.base
156
160
local_locked = None
157
161
local_base = None
158
162
self.hook_calls.append(
159
('post_push', source, local_base, master.base, old_revno, old_revid,
160
new_revno, new_revid, source.is_locked(), local_locked,
163
('post_push', result.source_branch, local_base,
164
result.master_branch.base,
165
result.old_revno, result.old_revid,
166
result.new_revno, result.new_revid,
167
result.source_branch.is_locked(), local_locked,
168
result.master_branch.is_locked()))
163
170
def test_post_push_empty_history(self):
164
171
target = self.make_branch('target')