~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bzrdir.py

  • Committer: Vincent Ladeuil
  • Date: 2010-08-31 08:25:15 UTC
  • mfrom: (5247.7.1 catch-them-all)
  • mto: This revision was merged to the branch mainline in revision 5400.
  • Revision ID: v.ladeuil+lp@free.fr-20100831082515-an9mtdmhalo7xaq0
Merge catch-them-all into more-ignored-exceptions

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
from bzrlib import (
27
27
    branch,
28
28
    bzrdir,
 
29
    controldir,
29
30
    errors,
30
31
    help_topics,
31
32
    repository,
69
70
        old_format = bzrdir.BzrDirFormat.get_default_format()
70
71
        # default is BzrDirFormat6
71
72
        self.failUnless(isinstance(old_format, bzrdir.BzrDirMetaFormat1))
72
 
        bzrdir.BzrDirFormat._set_default_format(SampleBzrDirFormat())
 
73
        controldir.ControlDirFormat._set_default_format(SampleBzrDirFormat())
73
74
        # creating a bzr dir should now create an instrumented dir.
74
75
        try:
75
76
            result = bzrdir.BzrDir.create('memory:///')
76
77
            self.failUnless(isinstance(result, SampleBzrDir))
77
78
        finally:
78
 
            bzrdir.BzrDirFormat._set_default_format(old_format)
 
79
            controldir.ControlDirFormat._set_default_format(old_format)
79
80
        self.assertEqual(old_format, bzrdir.BzrDirFormat.get_default_format())
80
81
 
81
82
 
82
83
class TestFormatRegistry(TestCase):
83
84
 
84
85
    def make_format_registry(self):
85
 
        my_format_registry = bzrdir.BzrDirFormatRegistry()
 
86
        my_format_registry = controldir.ControlDirFormatRegistry()
86
87
        my_format_registry.register('weave', bzrdir.BzrDirFormat6,
87
88
            'Pre-0.8 format.  Slower and does not support checkouts or shared'
88
89
            ' repositories', deprecated=True)
89
90
        my_format_registry.register_lazy('lazy', 'bzrlib.bzrdir',
90
91
            'BzrDirFormat6', 'Format registered lazily', deprecated=True)
91
 
        my_format_registry.register_metadir('knit',
 
92
        bzrdir.register_metadir(my_format_registry, 'knit',
92
93
            'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
93
94
            'Format using knits',
94
95
            )
95
96
        my_format_registry.set_default('knit')
96
 
        my_format_registry.register_metadir(
 
97
        bzrdir.register_metadir(my_format_registry,
97
98
            'branch6',
98
99
            'bzrlib.repofmt.knitrepo.RepositoryFormatKnit3',
99
100
            'Experimental successor to knit.  Use at your own risk.',
100
101
            branch_format='bzrlib.branch.BzrBranchFormat6',
101
102
            experimental=True)
102
 
        my_format_registry.register_metadir(
 
103
        bzrdir.register_metadir(my_format_registry,
103
104
            'hidden format',
104
105
            'bzrlib.repofmt.knitrepo.RepositoryFormatKnit3',
105
106
            'Experimental successor to knit.  Use at your own risk.',
174
175
            bzrdir.format_registry.set_default_repository(old_default)
175
176
 
176
177
    def test_aliases(self):
177
 
        a_registry = bzrdir.BzrDirFormatRegistry()
 
178
        a_registry = controldir.ControlDirFormatRegistry()
178
179
        a_registry.register('weave', bzrdir.BzrDirFormat6,
179
180
            'Pre-0.8 format.  Slower and does not support checkouts or shared'
180
181
            ' repositories', deprecated=True)
1058
1059
    def _known_formats(self):
1059
1060
        return set([NotBzrDirFormat()])
1060
1061
 
1061
 
    @classmethod
 
1062
 
 
1063
class NotBzrDirProber(controldir.Prober):
 
1064
 
1062
1065
    def probe_transport(self, transport):
1063
1066
        """Our format is present if the transport ends in '.not/'."""
1064
1067
        if transport.has('.not'):
1078
1081
        dir = format.initialize(self.get_url())
1079
1082
        self.assertIsInstance(dir, NotBzrDir)
1080
1083
        # now probe for it.
1081
 
        bzrlib.bzrdir.BzrDirFormat.register_control_format(format)
 
1084
        controldir.ControlDirFormat.register_prober(NotBzrDirProber)
1082
1085
        try:
1083
1086
            found = bzrlib.bzrdir.BzrDirFormat.find_format(
1084
1087
                get_transport(self.get_url()))
1085
1088
            self.assertIsInstance(found, NotBzrDirFormat)
1086
1089
        finally:
1087
 
            bzrlib.bzrdir.BzrDirFormat.unregister_control_format(format)
 
1090
            controldir.ControlDirFormat.unregister_prober(NotBzrDirProber)
1088
1091
 
1089
1092
    def test_included_in_known_formats(self):
1090
 
        bzrlib.bzrdir.BzrDirFormat.register_control_format(NotBzrDirFormat)
 
1093
        not_format = NotBzrDirFormat()
 
1094
        bzrlib.controldir.ControlDirFormat.register_format(not_format)
1091
1095
        try:
1092
1096
            formats = bzrlib.bzrdir.BzrDirFormat.known_formats()
1093
1097
            for format in formats:
1095
1099
                    return
1096
1100
            self.fail("No NotBzrDirFormat in %s" % formats)
1097
1101
        finally:
1098
 
            bzrlib.bzrdir.BzrDirFormat.unregister_control_format(NotBzrDirFormat)
 
1102
            bzrlib.controldir.ControlDirFormat.unregister_format(not_format)
1099
1103
 
1100
1104
 
1101
1105
class NonLocalTests(TestCaseWithTransport):