~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_missing.py

  • Committer: Marius Kruger
  • Date: 2008-12-31 14:29:30 UTC
  • mto: (3969.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 3970.
  • Revision ID: amanic@gmail.com-20081231142930-4i3efine315vu0vc
* add support for specifying a revision range to missing.find_unmerged
* test it
* let `restrict` parameter of TestFindUnmerged.assertUnmerged() default to 'all'

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,
 
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,
147
 
                                        backward=backward)
 
147
                                        backward=backward,
 
148
                                        revid_range=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)
157
158
 
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)
165
166
 
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,
174
175
                                               'remote')
182
183
        tree.merge_from_branch(tree2.branch)
183
184
        rev4 = tree.commit('four')
184
185
 
185
 
        self.assertUnmerged([('2', rev4)], [], tree.branch, tree2.branch, 'all')
 
186
        self.assertUnmerged([('2', rev4)], [], tree.branch, tree2.branch)
186
187
 
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,
215
216
                            backward=True)
 
217
 
 
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)]
 
230
 
 
231
        #control
 
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))
 
236
 
 
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))
 
242
 
 
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))
 
248
 
 
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))
 
254
 
 
255
    #todo:
 
256
    #def test_revision_range_local(self):
 
257
    #def test_revision_range_remote(self):
 
258
    #def test_revision_range_with_merges(self):