~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/interversionedfile_implementations/test_join.py

(mbp) merge bzr.dev to 0.8, prepare for release

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
                                          get_transport(self.get_url()),
34
34
                                          create=True)
35
35
 
36
 
    def get_target(self, name='target'):
 
36
    def get_target(self, name='target', create=True):
37
37
        """"Get an empty versioned file to join into."""
38
38
        return self.versionedfile_factory_to(name,
39
39
                                             get_transport(self.get_url()),
40
 
                                             create=True)
 
40
                                             create=create)
41
41
 
42
42
    def test_join(self):
43
43
        f1 = self.get_source()
267
267
            # switch source and target so source is ghostless
268
268
            t = source
269
269
            source = target
270
 
            target = source
 
270
            target = t
271
271
            source_ghosts = False
272
272
            target_ghosts = True
273
273
        # now target always supports ghosts.
306
306
                          },
307
307
                         target.get_graph_with_ghosts())
308
308
        self.assertFalse(target.has_ghost('base'))
 
309
 
 
310
    def test_restricted_join_into_empty(self):
 
311
        # joining into an empty versioned file with a version_ids list
 
312
        # should only grab the selected versions.
 
313
        source = self.get_source()
 
314
        source.add_lines('skip_me', [], ['a\n'])
 
315
        source.add_lines('inherit_me', [], ['b\n'])
 
316
        source.add_lines('select_me', ['inherit_me'], ['b\n'])
 
317
        target = self.get_target()
 
318
        target.join(source, version_ids=['select_me'])
 
319
        self.assertEqual(['inherit_me', 'select_me'], target.versions())
 
320
 
 
321
    def test_join_odd_records(self):
 
322
        # this tests that joining the 1st, 3rd and 5th records and not the
 
323
        # 2nd and 4th works, particularly after reopening the file.
 
324
        # this test is designed to test versioned files that perform
 
325
        # optimisations on the join. Grabbing partial data and reopening the
 
326
        # file make it likely to trigger a fault.
 
327
        source = self.get_source()
 
328
        source.add_lines('1', [], ['1st\n'])
 
329
        source.add_lines('2', [], ['2nd\n'])
 
330
        source.add_lines('3', ['1'], ['1st\n', '2nd\n'])
 
331
        source.add_lines('4', ['2'], ['1st\n'])
 
332
        source.add_lines('5', ['3'], ['1st\n', '2nd\n', '3rd\n'])
 
333
        target = self.get_target()
 
334
        target.join(source, version_ids=['1', '3', '5'])
 
335
        target = self.get_target(create=False)
 
336
        self.assertEqual(set(['1', '3', '5']), set(target.versions()))
 
337
        self.assertEqual(3, len(target.versions()))
 
338
        self.assertEqual(['1st\n'], target.get_lines('1'))
 
339
        self.assertEqual(['1st\n', '2nd\n'], target.get_lines('3'))
 
340
        self.assertEqual(['1st\n', '2nd\n', '3rd\n'], target.get_lines('5'))