~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_foreign.py

  • Committer: Vincent Ladeuil
  • Date: 2010-06-23 16:43:16 UTC
  • mto: (5247.3.43 smart-server-leaks)
  • mto: This revision was merged to the branch mainline in revision 5396.
  • Revision ID: v.ladeuil+lp@free.fr-20100623164316-yffl9m72oh8jy46a
Closing the connection is what pycurl was waiting for.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
from bzrlib import (
22
22
    branch,
23
23
    bzrdir,
24
 
    controldir,
25
24
    errors,
26
25
    foreign,
27
26
    lockable_files,
173
172
        super(DummyForeignVcsBranchFormat, self).__init__()
174
173
        self._matchingbzrdir = DummyForeignVcsDirFormat()
175
174
 
176
 
    def open(self, a_bzrdir, name=None, _found=False, found_repository=None):
 
175
    def open(self, a_bzrdir, name=None, _found=False):
177
176
        if not _found:
178
177
            raise NotImplementedError
179
178
        try:
180
179
            transport = a_bzrdir.get_branch_transport(None, name=name)
181
180
            control_files = lockable_files.LockableFiles(transport, 'lock',
182
181
                                                         lockdir.LockDir)
183
 
            if found_repository is None:
184
 
                found_repository = a_bzrdir.find_repository()
185
182
            return DummyForeignVcsBranch(_format=self,
186
183
                              _control_files=control_files,
187
184
                              a_bzrdir=a_bzrdir,
188
 
                              _repository=found_repository)
 
185
                              _repository=a_bzrdir.find_repository())
189
186
        except errors.NoSuchFile:
190
187
            raise errors.NotBranchError(path=transport.base)
191
188
 
208
205
    def get_branch_format(self):
209
206
        return DummyForeignVcsBranchFormat()
210
207
 
 
208
    @classmethod
 
209
    def probe_transport(klass, transport):
 
210
        """Return the .bzrdir style format present in a directory."""
 
211
        if not transport.has('.dummy'):
 
212
            raise errors.NotBranchError(path=transport.base)
 
213
        return klass()
 
214
 
211
215
    def initialize_on_transport(self, transport):
212
216
        """Initialize a new bzrdir in the base directory of a Transport."""
213
217
        # Since we don't have a .bzr directory, inherit the
262
266
 
263
267
 
264
268
def register_dummy_foreign_for_test(testcase):
265
 
    controldir.ControlDirFormat.register_format(DummyForeignVcsDirFormat)
266
 
    testcase.addCleanup(controldir.ControlDirFormat.unregister_format,
 
269
    bzrdir.BzrDirFormat.register_control_format(DummyForeignVcsDirFormat)
 
270
    testcase.addCleanup(bzrdir.BzrDirFormat.unregister_control_format,
267
271
                        DummyForeignVcsDirFormat)
268
 
    controldir.ControlDirFormat.register_prober(DummyForeignProber)
269
 
    testcase.addCleanup(controldir.ControlDirFormat.unregister_prober,
270
 
        DummyForeignProber)
271
272
    # We need to register the optimiser to make the dummy appears really
272
273
    # different from a regular bzr repository.
273
274
    branch.InterBranch.register_optimiser(InterToDummyVcsBranch)
275
276
                        InterToDummyVcsBranch)
276
277
 
277
278
 
278
 
class DummyForeignProber(controldir.Prober):
279
 
 
280
 
    @classmethod
281
 
    def probe_transport(klass, transport):
282
 
        """Return the .bzrdir style format present in a directory."""
283
 
        if not transport.has('.dummy'):
284
 
            raise errors.NotBranchError(path=transport.base)
285
 
        return DummyForeignVcsDirFormat()
286
 
 
287
 
 
288
279
class ForeignVcsRegistryTests(tests.TestCase):
289
280
    """Tests for the ForeignVcsRegistry class."""
290
281