~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_missing.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-01-27 20:24:43 UTC
  • mfrom: (3960.2.1 1.12-progress-warnings)
  • Revision ID: pqm@pqm.ubuntu.com-20090127202443-ty2bu1hh91dumasz
(jam) Avoid getting a UserWarning by not creating an unused progress
        bar.

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='all', include_merges=False, backward=False,
142
 
            local_revid_range=None, remote_revid_range=None):
 
141
                       restrict, include_merges=False,
 
142
                       backward=False):
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, backward=backward,
147
 
            local_revid_range=local_revid_range,
148
 
            remote_revid_range=remote_revid_range)
 
145
                                        local_branch, remote_branch, restrict,
 
146
                                        include_merges=include_merges,
 
147
                                        backward=backward)
149
148
        self.assertEqual(local, local_extra)
150
149
        self.assertEqual(remote, remote_extra)
151
150
 
154
153
        rev1 = tree.commit('one')
155
154
        tree.lock_read()
156
155
        self.addCleanup(tree.unlock)
157
 
        self.assertUnmerged([], [], tree.branch, tree.branch)
158
 
        self.assertUnmerged([], [], tree.branch, tree.branch,
159
 
            local_revid_range=(rev1, rev1))
 
156
        self.assertUnmerged([], [], tree.branch, tree.branch, 'all')
160
157
 
161
158
    def test_one_ahead(self):
162
159
        tree = self.make_branch_and_tree('tree')
163
160
        rev1 = tree.commit('one')
164
161
        tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
165
162
        rev2 = tree2.commit('two')
166
 
        self.assertUnmerged([], [('2', rev2)], tree.branch, tree2.branch)
167
 
        self.assertUnmerged([('2', rev2)], [], tree2.branch, tree.branch)
 
163
        self.assertUnmerged([], [('2', rev2)], tree.branch, tree2.branch, 'all')
 
164
        self.assertUnmerged([('2', rev2)], [], tree2.branch, tree.branch, 'all')
168
165
 
169
166
    def test_restrict(self):
170
167
        tree = self.make_branch_and_tree('tree')
171
168
        rev1 = tree.commit('one')
172
169
        tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
173
170
        rev2 = tree2.commit('two')
174
 
        self.assertUnmerged([], [('2', rev2)], tree.branch, tree2.branch)
 
171
        self.assertUnmerged([], [('2', rev2)], tree.branch, tree2.branch, 'all')
175
172
        self.assertUnmerged([], None, tree.branch, tree2.branch, 'local')
176
173
        self.assertUnmerged(None, [('2', rev2)], tree.branch, tree2.branch,
177
174
                                               'remote')
185
182
        tree.merge_from_branch(tree2.branch)
186
183
        rev4 = tree.commit('four')
187
184
 
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))
 
185
        self.assertUnmerged([('2', rev4)], [], tree.branch, tree2.branch, 'all')
193
186
 
194
187
    def test_include_merges(self):
195
188
        tree = self.make_branch_and_tree('tree')
206
199
        tree2.merge_from_branch(tree3.branch)
207
200
        rev6 = tree2.commit('six', rev_id='rev6')
208
201
 
209
 
        self.assertUnmerged([], [('2', 'rev2', 0), ('3', 'rev3', 0),
 
202
        self.assertUnmerged([], [('2', 'rev2', 0), ('3', 'rev3',0 ),
210
203
                                 ('4', 'rev6', 0),
211
204
                                 ('3.1.1', 'rev4', 1), ('3.1.2', 'rev5', 1),
212
205
                                 ],
213
 
                            tree.branch, tree2.branch,
 
206
                            tree.branch, tree2.branch, 'all',
214
207
                            include_merges=True)
215
208
 
216
209
        self.assertUnmerged([], [('4', 'rev6', 0),
217
210
                                 ('3.1.2', 'rev5', 1), ('3.1.1', 'rev4', 1),
218
 
                                 ('3', 'rev3', 0), ('2', 'rev2', 0),
 
211
                                 ('3', 'rev3',0 ), ('2', 'rev2', 0),
219
212
                                 ],
220
 
                            tree.branch, tree2.branch,
 
213
                            tree.branch, tree2.branch, 'all',
221
214
                            include_merges=True,
222
215
                            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))