~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_foreign.py

merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2008-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
173
173
        super(DummyForeignVcsBranchFormat, self).__init__()
174
174
        self._matchingbzrdir = DummyForeignVcsDirFormat()
175
175
 
176
 
    def open(self, a_bzrdir, name=None, _found=False):
 
176
    def open(self, a_bzrdir, name=None, _found=False, found_repository=None):
177
177
        if not _found:
178
178
            raise NotImplementedError
179
179
        try:
180
180
            transport = a_bzrdir.get_branch_transport(None, name=name)
181
181
            control_files = lockable_files.LockableFiles(transport, 'lock',
182
182
                                                         lockdir.LockDir)
 
183
            if found_repository is None:
 
184
                found_repository = a_bzrdir.find_repository()
183
185
            return DummyForeignVcsBranch(_format=self,
184
186
                              _control_files=control_files,
185
187
                              a_bzrdir=a_bzrdir,
186
 
                              _repository=a_bzrdir.find_repository())
 
188
                              _repository=found_repository)
187
189
        except errors.NoSuchFile:
188
190
            raise errors.NotBranchError(path=transport.base)
189
191
 
260
262
 
261
263
 
262
264
def register_dummy_foreign_for_test(testcase):
263
 
    controldir.ControlDirFormat.register_format(DummyForeignVcsDirFormat)
264
 
    testcase.addCleanup(controldir.ControlDirFormat.unregister_format,
265
 
                        DummyForeignVcsDirFormat)
266
265
    controldir.ControlDirFormat.register_prober(DummyForeignProber)
267
266
    testcase.addCleanup(controldir.ControlDirFormat.unregister_prober,
268
267
        DummyForeignProber)
282
281
            raise errors.NotBranchError(path=transport.base)
283
282
        return DummyForeignVcsDirFormat()
284
283
 
 
284
    @classmethod
 
285
    def known_formats(cls):
 
286
        return set([DummyForeignVcsDirFormat()])
 
287
 
285
288
 
286
289
class ForeignVcsRegistryTests(tests.TestCase):
287
290
    """Tests for the ForeignVcsRegistry class."""