~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_foreign.py

  • Committer: Andrew Bennetts
  • Date: 2010-04-14 06:47:18 UTC
  • mto: This revision was merged to the branch mainline in revision 5155.
  • Revision ID: andrew.bennetts@canonical.com-20100414064718-130ptdug4opfjj6b
Link to Python bug in comment.

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,
91
90
        self._format = _format
92
91
        self._base = a_bzrdir.transport.base
93
92
        self._ignore_fallbacks = False
94
 
        self.bzrdir = a_bzrdir
95
93
        foreign.ForeignBranch.__init__(self, 
96
94
            DummyForeignVcsMapping(DummyForeignVcs()))
97
95
        branch.BzrBranch6.__init__(self, _format, _control_files, a_bzrdir, 
206
204
    def get_branch_format(self):
207
205
        return DummyForeignVcsBranchFormat()
208
206
 
 
207
    @classmethod
 
208
    def probe_transport(klass, transport):
 
209
        """Return the .bzrdir style format present in a directory."""
 
210
        if not transport.has('.dummy'):
 
211
            raise errors.NotBranchError(path=transport.base)
 
212
        return klass()
 
213
 
209
214
    def initialize_on_transport(self, transport):
210
215
        """Initialize a new bzrdir in the base directory of a Transport."""
211
216
        # Since we don't have a .bzr directory, inherit the
260
265
 
261
266
 
262
267
def register_dummy_foreign_for_test(testcase):
263
 
    controldir.ControlDirFormat.register_format(DummyForeignVcsDirFormat)
264
 
    testcase.addCleanup(controldir.ControlDirFormat.unregister_format,
 
268
    bzrdir.BzrDirFormat.register_control_format(DummyForeignVcsDirFormat)
 
269
    testcase.addCleanup(bzrdir.BzrDirFormat.unregister_control_format,
265
270
                        DummyForeignVcsDirFormat)
266
 
    controldir.ControlDirFormat.register_prober(DummyForeignProber)
267
 
    testcase.addCleanup(controldir.ControlDirFormat.unregister_prober,
268
 
        DummyForeignProber)
269
271
    # We need to register the optimiser to make the dummy appears really
270
272
    # different from a regular bzr repository.
271
273
    branch.InterBranch.register_optimiser(InterToDummyVcsBranch)
273
275
                        InterToDummyVcsBranch)
274
276
 
275
277
 
276
 
class DummyForeignProber(controldir.Prober):
277
 
 
278
 
    @classmethod
279
 
    def probe_transport(klass, transport):
280
 
        """Return the .bzrdir style format present in a directory."""
281
 
        if not transport.has('.dummy'):
282
 
            raise errors.NotBranchError(path=transport.base)
283
 
        return DummyForeignVcsDirFormat()
284
 
 
285
 
 
286
278
class ForeignVcsRegistryTests(tests.TestCase):
287
279
    """Tests for the ForeignVcsRegistry class."""
288
280