138
138
class TestFindUnmerged(tests.TestCaseWithTransport):
140
140
def assertUnmerged(self, local, remote, local_branch, remote_branch,
141
restrict, include_merges=False,
141
restrict='all', include_merges=False,
142
backward=False, revid_range=None):
143
143
"""Check the output of find_unmerged_mainline_revisions"""
144
144
local_extra, remote_extra = missing.find_unmerged(
145
145
local_branch, remote_branch, restrict,
146
146
include_merges=include_merges,
148
revid_range=revid_range)
148
149
self.assertEqual(local, local_extra)
149
150
self.assertEqual(remote, remote_extra)
153
154
rev1 = tree.commit('one')
155
156
self.addCleanup(tree.unlock)
156
self.assertUnmerged([], [], tree.branch, tree.branch, 'all')
157
self.assertUnmerged([], [], tree.branch, tree.branch)
158
159
def test_one_ahead(self):
159
160
tree = self.make_branch_and_tree('tree')
160
161
rev1 = tree.commit('one')
161
162
tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
162
163
rev2 = tree2.commit('two')
163
self.assertUnmerged([], [('2', rev2)], tree.branch, tree2.branch, 'all')
164
self.assertUnmerged([('2', rev2)], [], tree2.branch, tree.branch, 'all')
164
self.assertUnmerged([], [('2', rev2)], tree.branch, tree2.branch)
165
self.assertUnmerged([('2', rev2)], [], tree2.branch, tree.branch)
166
167
def test_restrict(self):
167
168
tree = self.make_branch_and_tree('tree')
168
169
rev1 = tree.commit('one')
169
170
tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
170
171
rev2 = tree2.commit('two')
171
self.assertUnmerged([], [('2', rev2)], tree.branch, tree2.branch, 'all')
172
self.assertUnmerged([], [('2', rev2)], tree.branch, tree2.branch)
172
173
self.assertUnmerged([], None, tree.branch, tree2.branch, 'local')
173
174
self.assertUnmerged(None, [('2', rev2)], tree.branch, tree2.branch,
182
183
tree.merge_from_branch(tree2.branch)
183
184
rev4 = tree.commit('four')
185
self.assertUnmerged([('2', rev4)], [], tree.branch, tree2.branch, 'all')
186
self.assertUnmerged([('2', rev4)], [], tree.branch, tree2.branch)
187
188
def test_include_merges(self):
188
189
tree = self.make_branch_and_tree('tree')
213
214
tree.branch, tree2.branch, 'all',
214
215
include_merges=True,
218
def test_revision_range_all(self):
219
local = self.make_branch_and_tree('local')
220
lrevid1 = local.commit('one')
221
remote = local.bzrdir.sprout('remote').open_workingtree()
222
rrevid2 = remote.commit('two')
223
rrevid3 = remote.commit('three')
224
rrevid4 = remote.commit('four')
225
lrevid2 = local.commit('two')
226
lrevid3 = local.commit('three')
227
lrevid4 = local.commit('four')
228
local_extra = [('2', lrevid2), ('3', lrevid3), ('4', lrevid4)]
229
remote_extra = [('2', rrevid2), ('3', rrevid3), ('4', rrevid4)]
232
self.assertUnmerged(local_extra, remote_extra,
233
local.branch, remote.branch)
234
self.assertUnmerged(local_extra, remote_extra,
235
local.branch, remote.branch, revid_range=(None, None))
237
#exclude revisions higher than rrevid2
238
self.assertUnmerged(local_extra, [('2', rrevid2)],
239
local.branch, remote.branch, revid_range=(None, rrevid2))
240
self.assertUnmerged(local_extra, [('2', rrevid2)],
241
local.branch, remote.branch, revid_range=(lrevid1, rrevid2))
243
#exclude local revisions
244
self.assertUnmerged([('2', lrevid2)], remote_extra,
245
local.branch, remote.branch, revid_range=(lrevid2, lrevid2))
246
self.assertUnmerged([('2', lrevid2), ('3', lrevid3)], remote_extra,
247
local.branch, remote.branch, revid_range=(lrevid2, lrevid3))
249
#exclude remote revisions
250
self.assertUnmerged(local_extra, [('2', rrevid2)],
251
local.branch, remote.branch, revid_range=(rrevid2, rrevid2))
252
self.assertUnmerged(local_extra, [('2', rrevid2), ('3', rrevid3)],
253
local.branch, remote.branch, revid_range=(rrevid2, rrevid3))
256
#def test_revision_range_local(self):
257
#def test_revision_range_remote(self):
258
#def test_revision_range_with_merges(self):