~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-05-03 22:01:07 UTC
  • mfrom: (1692.4.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060503220107-7606072537025d30
Merge in push-without-working-tree, knit-sftp-speed, reconcile-fixes-revision-graph-cache.

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()
317
317
        target = self.get_target()
318
318
        target.join(source, version_ids=['select_me'])
319
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'))