~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_repository.py

  • Committer: Jelmer Vernooij
  • Date: 2012-04-16 11:08:11 UTC
  • mfrom: (6521 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6522.
  • Revision ID: jelmer@samba.org-20120416110811-0y996ihqy9o2bb1t
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
    )
46
46
from bzrlib import (
47
47
    bzrdir,
 
48
    controldir,
48
49
    errors,
49
50
    inventory,
50
51
    osutils,
66
67
class TestDefaultFormat(TestCase):
67
68
 
68
69
    def test_get_set_default_format(self):
69
 
        old_default = bzrdir.format_registry.get('default')
 
70
        old_default = controldir.format_registry.get('default')
70
71
        private_default = old_default().repository_format.__class__
71
72
        old_format = repository.format_registry.get_default()
72
73
        self.assertTrue(isinstance(old_format, private_default))
74
75
            my_bzrdir = bzrdir.BzrDirMetaFormat1()
75
76
            my_bzrdir.repository_format = SampleRepositoryFormat()
76
77
            return my_bzrdir
77
 
        bzrdir.format_registry.remove('default')
78
 
        bzrdir.format_registry.register('sample', make_sample_bzrdir, '')
79
 
        bzrdir.format_registry.set_default('sample')
 
78
        controldir.format_registry.remove('default')
 
79
        controldir.format_registry.register('sample', make_sample_bzrdir, '')
 
80
        controldir.format_registry.set_default('sample')
80
81
        # creating a repository should now create an instrumented dir.
81
82
        try:
82
83
            # the default branch format is used by the meta dir format
85
86
            result = dir.create_repository()
86
87
            self.assertEqual(result, 'A bzr repository dir')
87
88
        finally:
88
 
            bzrdir.format_registry.remove('default')
89
 
            bzrdir.format_registry.remove('sample')
90
 
            bzrdir.format_registry.register('default', old_default, '')
 
89
            controldir.format_registry.remove('default')
 
90
            controldir.format_registry.remove('sample')
 
91
            controldir.format_registry.register('default', old_default, '')
91
92
        self.assertIsInstance(repository.format_registry.get_default(),
92
93
                              old_format.__class__)
93
94
 
236
237
    def test_attribute__fetch_order(self):
237
238
        """Knits need topological data insertion."""
238
239
        repo = self.make_repository('.',
239
 
                format=bzrdir.format_registry.get('knit')())
 
240
                format=controldir.format_registry.get('knit')())
240
241
        self.assertEqual('topological', repo._format._fetch_order)
241
242
 
242
243
    def test_attribute__fetch_uses_deltas(self):
243
244
        """Knits reuse deltas."""
244
245
        repo = self.make_repository('.',
245
 
                format=bzrdir.format_registry.get('knit')())
 
246
                format=controldir.format_registry.get('knit')())
246
247
        self.assertEqual(True, repo._format._fetch_uses_deltas)
247
248
 
248
249
    def test_disk_layout(self):
334
335
        is valid when the api is not being abused.
335
336
        """
336
337
        repo = self.make_repository('.',
337
 
                format=bzrdir.format_registry.get('knit')())
 
338
                format=controldir.format_registry.get('knit')())
338
339
        inv_xml = '<inventory format="5">\n</inventory>\n'
339
340
        inv = repo._deserialise_inventory('test-rev-id', inv_xml)
340
341
        self.assertEqual('test-rev-id', inv.root.revision)
342
343
    def test_deserialise_uses_global_revision_id(self):
343
344
        """If it is set, then we re-use the global revision id"""
344
345
        repo = self.make_repository('.',
345
 
                format=bzrdir.format_registry.get('knit')())
 
346
                format=controldir.format_registry.get('knit')())
346
347
        inv_xml = ('<inventory format="5" revision_id="other-rev-id">\n'
347
348
                   '</inventory>\n')
348
349
        # Arguably, the deserialise_inventory should detect a mismatch, and
355
356
 
356
357
    def test_supports_external_lookups(self):
357
358
        repo = self.make_repository('.',
358
 
                format=bzrdir.format_registry.get('knit')())
 
359
                format=controldir.format_registry.get('knit')())
359
360
        self.assertFalse(repo._format.supports_external_lookups)
360
361
 
361
362
 
524
525
        revision_tree.lock_read()
525
526
        try:
526
527
            self.assertRaises(errors.NoSuchFile, revision_tree.get_file_lines,
527
 
                revision_tree.inventory.root.file_id)
 
528
                revision_tree.get_root_id())
528
529
        finally:
529
530
            revision_tree.unlock()
530
531
        format = bzrdir.BzrDirMetaFormat1()
534
535
        revision_tree = tree.branch.repository.revision_tree('dull')
535
536
        revision_tree.lock_read()
536
537
        try:
537
 
            revision_tree.get_file_lines(revision_tree.inventory.root.file_id)
 
538
            revision_tree.get_file_lines(revision_tree.get_root_id())
538
539
        finally:
539
540
            revision_tree.unlock()
540
541
        tree.commit("Another dull commit", rev_id='dull2')
541
542
        revision_tree = tree.branch.repository.revision_tree('dull2')
542
543
        revision_tree.lock_read()
543
544
        self.addCleanup(revision_tree.unlock)
544
 
        self.assertEqual('dull', revision_tree.inventory.root.revision)
 
545
        self.assertEqual('dull',
 
546
                revision_tree.get_file_revision(revision_tree.get_root_id()))
545
547
 
546
548
    def test_supports_external_lookups(self):
547
549
        format = bzrdir.BzrDirMetaFormat1()
993
995
class TestRepositoryPackCollection(TestCaseWithTransport):
994
996
 
995
997
    def get_format(self):
996
 
        return bzrdir.format_registry.make_bzrdir('pack-0.92')
 
998
        return controldir.format_registry.make_bzrdir('pack-0.92')
997
999
 
998
1000
    def get_packs(self):
999
1001
        format = self.get_format()