~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_versionedfile.py

Merge transaction finalisation and ensure iter_lines_added_or_present in knits does a old-to-new read in the knit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
93
93
 
94
94
        self.assertRaises(RevisionNotPresent,
95
95
            f.get_ancestry, ['rM', 'rX'])
 
96
 
 
97
    def test_mutate_after_finish(self):
 
98
        f = self.get_file()
 
99
        f.transaction_finished()
 
100
        self.assertRaises(errors.OutSideTransaction, f.add_lines, '', [], [])
 
101
        self.assertRaises(errors.OutSideTransaction, f.add_lines_with_ghosts, '', [], [])
 
102
        self.assertRaises(errors.OutSideTransaction, f.fix_parents, '', [])
 
103
        self.assertRaises(errors.OutSideTransaction, f.join, '')
 
104
        self.assertRaises(errors.OutSideTransaction, f.clone_text, 'base', 'bar', ['foo'])
96
105
        
97
106
    def test_clear_cache(self):
98
107
        f = self.get_file()
372
381
        self.assertEquals(('base', 'line\n'), origins[0])
373
382
        self.assertEquals(('base', 'line_b\n'), origins[1])
374
383
        self.assertEquals(('references_ghost', 'line_c\n'), origins[2])
 
384
 
 
385
    def test_readonly_mode(self):
 
386
        transport = get_transport(self.get_url('.'))
 
387
        factory = self.get_factory()
 
388
        vf = factory('id', transport, 0777, create=True, access_mode='w')
 
389
        vf = factory('id', transport, access_mode='r')
 
390
        self.assertRaises(errors.ReadOnlyError, vf.add_lines, 'base', [], [])
 
391
        self.assertRaises(errors.ReadOnlyError,
 
392
                          vf.add_lines_with_ghosts,
 
393
                          'base',
 
394
                          [],
 
395
                          [])
 
396
        self.assertRaises(errors.ReadOnlyError, vf.fix_parents, 'base', [])
 
397
        self.assertRaises(errors.ReadOnlyError, vf.join, 'base')
 
398
        self.assertRaises(errors.ReadOnlyError, vf.clone_text, 'base', 'bar', ['foo'])
375
399
        
376
400
 
377
401
class TestWeave(TestCaseWithTransport, VersionedFileTestMixIn):
422
446
                          'foo',
423
447
                          get_transport(self.get_url('.')))
424
448
 
 
449
    def get_factory(self):
 
450
        return WeaveFile
 
451
 
425
452
 
426
453
class TestKnit(TestCaseWithTransport, VersionedFileTestMixIn):
427
454
 
429
456
        return KnitVersionedFile(name, get_transport(self.get_url('.')),
430
457
                                 delta=True, create=True)
431
458
 
 
459
    def get_factory(self):
 
460
        return KnitVersionedFile
 
461
 
432
462
    def get_file_corrupted_text(self):
433
463
        knit = self.get_file()
434
464
        knit.add_lines('v1', [], ['hello\n'])