~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_branch.py

Merge pt1 hooks branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
147
147
        return "opened supported branch."
148
148
 
149
149
 
 
150
class SampleExtraBranchFormat(_mod_branch.BranchFormat):
 
151
    """A sample format that is not usable in a metadir."""
 
152
 
 
153
    def get_format_string(self):
 
154
        # This format is not usable in a metadir.
 
155
        return None
 
156
 
 
157
    def network_name(self):
 
158
        # Network name always has to be provided.
 
159
        return "extra"
 
160
 
 
161
    def initialize(self, a_bzrdir, name=None):
 
162
        raise NotImplementedError(self.initialize)
 
163
 
 
164
    def open(self, transport, name=None, _found=False, ignore_fallbacks=False):
 
165
        raise NotImplementedError(self.open)
 
166
 
 
167
 
150
168
class TestBzrBranchFormat(tests.TestCaseWithTransport):
151
169
    """Tests for the BzrBranchFormat facility."""
152
170
 
163
181
            self.failUnless(isinstance(found_format, format.__class__))
164
182
        check_format(_mod_branch.BzrBranchFormat5(), "bar")
165
183
 
 
184
    def test_extra_format(self):
 
185
        dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
 
186
        SampleSupportedBranchFormat().initialize(dir)
 
187
        format = SampleExtraBranchFormat()
 
188
        _mod_branch.BranchFormat.register_extra_format(format)
 
189
        self.addCleanup(_mod_branch.BranchFormat.unregister_extra_format,
 
190
            format)
 
191
        self.assertTrue(format in _mod_branch.BranchFormat.get_formats())
 
192
        self.assertEquals(format,
 
193
            _mod_branch.network_format_registry.get("extra"))
 
194
 
166
195
    def test_find_format_factory(self):
167
196
        dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
168
197
        SampleSupportedBranchFormat().initialize(dir)
480
509
 
481
510
    def test_create_open_reference(self):
482
511
        bzrdirformat = bzrdir.BzrDirMetaFormat1()
483
 
        t = transport.get_transport(self.get_url('.'))
 
512
        t = self.get_transport()
484
513
        t.mkdir('repo')
485
514
        dir = bzrdirformat.initialize(self.get_url('repo'))
486
515
        dir.create_repository()