~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_missing.py

  • Committer: Ian Clatworthy
  • Date: 2009-01-29 05:21:36 UTC
  • mfrom: (3921.3.14 bzr.missing_revision)
  • mto: This revision was merged to the branch mainline in revision 3970.
  • Revision ID: ian.clatworthy@canonical.com-20090129052136-1a0ue2k2rhxznu23
Add local & remote revision filtering to missing (Marius Kruger)

Show diffs side-by-side

added added

removed removed

Lines of Context:
138
138
class TestFindUnmerged(tests.TestCaseWithTransport):
139
139
 
140
140
    def assertUnmerged(self, local, remote, local_branch, remote_branch,
141
 
                       restrict, include_merges=False,
142
 
                       backward=False):
 
141
            restrict='all', include_merges=False, backward=False,
 
142
            local_revid_range=None, remote_revid_range=None):
143
143
        """Check the output of find_unmerged_mainline_revisions"""
144
144
        local_extra, remote_extra = missing.find_unmerged(
145
 
                                        local_branch, remote_branch, restrict,
146
 
                                        include_merges=include_merges,
147
 
                                        backward=backward)
 
145
            local_branch, remote_branch, restrict,
 
146
            include_merges=include_merges, backward=backward,
 
147
            local_revid_range=local_revid_range,
 
148
            remote_revid_range=remote_revid_range)
148
149
        self.assertEqual(local, local_extra)
149
150
        self.assertEqual(remote, remote_extra)
150
151
 
153
154
        rev1 = tree.commit('one')
154
155
        tree.lock_read()
155
156
        self.addCleanup(tree.unlock)
156
 
        self.assertUnmerged([], [], tree.branch, tree.branch, 'all')
 
157
        self.assertUnmerged([], [], tree.branch, tree.branch)
 
158
        self.assertUnmerged([], [], tree.branch, tree.branch,
 
159
            local_revid_range=(rev1, rev1))
157
160
 
158
161
    def test_one_ahead(self):
159
162
        tree = self.make_branch_and_tree('tree')
160
163
        rev1 = tree.commit('one')
161
164
        tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
162
165
        rev2 = tree2.commit('two')
163
 
        self.assertUnmerged([], [('2', rev2)], tree.branch, tree2.branch, 'all')
164
 
        self.assertUnmerged([('2', rev2)], [], tree2.branch, tree.branch, 'all')
 
166
        self.assertUnmerged([], [('2', rev2)], tree.branch, tree2.branch)
 
167
        self.assertUnmerged([('2', rev2)], [], tree2.branch, tree.branch)
165
168
 
166
169
    def test_restrict(self):
167
170
        tree = self.make_branch_and_tree('tree')
168
171
        rev1 = tree.commit('one')
169
172
        tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
170
173
        rev2 = tree2.commit('two')
171
 
        self.assertUnmerged([], [('2', rev2)], tree.branch, tree2.branch, 'all')
 
174
        self.assertUnmerged([], [('2', rev2)], tree.branch, tree2.branch)
172
175
        self.assertUnmerged([], None, tree.branch, tree2.branch, 'local')
173
176
        self.assertUnmerged(None, [('2', rev2)], tree.branch, tree2.branch,
174
177
                                               'remote')
182
185
        tree.merge_from_branch(tree2.branch)
183
186
        rev4 = tree.commit('four')
184
187
 
185
 
        self.assertUnmerged([('2', rev4)], [], tree.branch, tree2.branch, 'all')
 
188
        self.assertUnmerged([('2', rev4)], [], tree.branch, tree2.branch)
 
189
        self.assertUnmerged([('2', rev4)], [], tree.branch, tree2.branch,
 
190
            local_revid_range=(rev4, rev4))
 
191
        self.assertUnmerged([], [], tree.branch, tree2.branch,
 
192
            local_revid_range=(rev1, rev1))
186
193
 
187
194
    def test_include_merges(self):
188
195
        tree = self.make_branch_and_tree('tree')
199
206
        tree2.merge_from_branch(tree3.branch)
200
207
        rev6 = tree2.commit('six', rev_id='rev6')
201
208
 
202
 
        self.assertUnmerged([], [('2', 'rev2', 0), ('3', 'rev3',0 ),
 
209
        self.assertUnmerged([], [('2', 'rev2', 0), ('3', 'rev3', 0),
203
210
                                 ('4', 'rev6', 0),
204
211
                                 ('3.1.1', 'rev4', 1), ('3.1.2', 'rev5', 1),
205
212
                                 ],
206
 
                            tree.branch, tree2.branch, 'all',
 
213
                            tree.branch, tree2.branch,
207
214
                            include_merges=True)
208
215
 
209
216
        self.assertUnmerged([], [('4', 'rev6', 0),
210
217
                                 ('3.1.2', 'rev5', 1), ('3.1.1', 'rev4', 1),
211
 
                                 ('3', 'rev3',0 ), ('2', 'rev2', 0),
 
218
                                 ('3', 'rev3', 0), ('2', 'rev2', 0),
212
219
                                 ],
213
 
                            tree.branch, tree2.branch, 'all',
 
220
                            tree.branch, tree2.branch,
214
221
                            include_merges=True,
215
222
                            backward=True)
 
223
 
 
224
        self.assertUnmerged([], [('4', 'rev6', 0)],
 
225
            tree.branch, tree2.branch,
 
226
            include_merges=True, remote_revid_range=(rev6, rev6))
 
227
 
 
228
        self.assertUnmerged([], [('3', 'rev3', 0), ('3.1.1', 'rev4', 1)],
 
229
                    tree.branch, tree2.branch,
 
230
                    include_merges=True, remote_revid_range=(rev3, rev4))
 
231
 
 
232
        self.assertUnmerged([], [('4', 'rev6', 0), ('3.1.2', 'rev5', 1)],
 
233
                    tree.branch, tree2.branch,
 
234
                    include_merges=True, remote_revid_range=(rev5, rev6))
 
235
 
 
236
    def test_revision_range(self):
 
237
        local = self.make_branch_and_tree('local')
 
238
        lrevid1 = local.commit('one')
 
239
        remote = local.bzrdir.sprout('remote').open_workingtree()
 
240
        rrevid2 = remote.commit('two')
 
241
        rrevid3 = remote.commit('three')
 
242
        rrevid4 = remote.commit('four')
 
243
        lrevid2 = local.commit('two')
 
244
        lrevid3 = local.commit('three')
 
245
        lrevid4 = local.commit('four')
 
246
        local_extra = [('2', lrevid2), ('3', lrevid3), ('4', lrevid4)]
 
247
        remote_extra = [('2', rrevid2), ('3', rrevid3), ('4', rrevid4)]
 
248
 
 
249
        # control
 
250
        self.assertUnmerged(local_extra, remote_extra,
 
251
            local.branch, remote.branch)
 
252
        self.assertUnmerged(local_extra, remote_extra,
 
253
            local.branch, remote.branch, local_revid_range=(None, None),
 
254
            remote_revid_range=(None, None))
 
255
 
 
256
        # exclude local revisions
 
257
        self.assertUnmerged([('2', lrevid2)], remote_extra,
 
258
            local.branch, remote.branch, local_revid_range=(lrevid2, lrevid2))
 
259
        self.assertUnmerged([('2', lrevid2), ('3', lrevid3)], remote_extra,
 
260
            local.branch, remote.branch, local_revid_range=(lrevid2, lrevid3))
 
261
        self.assertUnmerged([('2', lrevid2), ('3', lrevid3)], None,
 
262
            local.branch, remote.branch, 'local',
 
263
            local_revid_range=(lrevid2, lrevid3))
 
264
 
 
265
        # exclude remote revisions
 
266
        self.assertUnmerged(local_extra, [('2', rrevid2)],
 
267
            local.branch, remote.branch, remote_revid_range=(None, rrevid2))
 
268
        self.assertUnmerged(local_extra, [('2', rrevid2)],
 
269
            local.branch, remote.branch, remote_revid_range=(lrevid1, rrevid2))
 
270
        self.assertUnmerged(local_extra, [('2', rrevid2)],
 
271
            local.branch, remote.branch, remote_revid_range=(rrevid2, rrevid2))
 
272
        self.assertUnmerged(local_extra, [('2', rrevid2), ('3', rrevid3)],
 
273
            local.branch, remote.branch, remote_revid_range=(None, rrevid3))
 
274
        self.assertUnmerged(local_extra, [('2', rrevid2), ('3', rrevid3)],
 
275
            local.branch, remote.branch, remote_revid_range=(rrevid2, rrevid3))
 
276
        self.assertUnmerged(local_extra, [('3', rrevid3)],
 
277
            local.branch, remote.branch, remote_revid_range=(rrevid3, rrevid3))
 
278
        self.assertUnmerged(None, [('2', rrevid2), ('3', rrevid3)],
 
279
            local.branch, remote.branch, 'remote',
 
280
            remote_revid_range=(rrevid2, rrevid3))
 
281
 
 
282
        # exclude local and remote revisions
 
283
        self.assertUnmerged([('3', lrevid3)], [('3', rrevid3)],
 
284
            local.branch, remote.branch, local_revid_range=(lrevid3, lrevid3),
 
285
            remote_revid_range=(rrevid3, rrevid3))