~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_foreign.py

  • Committer: John Arbash Meinel
  • Date: 2010-02-17 17:11:16 UTC
  • mfrom: (4797.2.17 2.1)
  • mto: (4797.2.18 2.1)
  • mto: This revision was merged to the branch mainline in revision 5055.
  • Revision ID: john@arbash-meinel.com-20100217171116-h7t9223ystbnx5h8
merge bzr.2.1 in preparation for NEWS entry.

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, 
173
171
        super(DummyForeignVcsBranchFormat, self).__init__()
174
172
        self._matchingbzrdir = DummyForeignVcsDirFormat()
175
173
 
176
 
    def open(self, a_bzrdir, name=None, _found=False):
 
174
    def open(self, a_bzrdir, _found=False):
177
175
        if not _found:
178
176
            raise NotImplementedError
179
177
        try:
180
 
            transport = a_bzrdir.get_branch_transport(None, name=name)
 
178
            transport = a_bzrdir.get_branch_transport(None)
181
179
            control_files = lockable_files.LockableFiles(transport, 'lock',
182
180
                                                         lockdir.LockDir)
183
181
            return DummyForeignVcsBranch(_format=self,
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
238
243
        self._control_files = lockable_files.LockableFiles(self.transport,
239
244
            "lock", lockable_files.TransportLock)
240
245
 
241
 
    def open_branch(self, name=None, unsupported=False, ignore_fallbacks=True):
242
 
        if name is not None:
243
 
            raise errors.NoColocatedBranchSupport(self)
 
246
    def open_branch(self, ignore_fallbacks=True):
244
247
        return self._format.get_branch_format().open(self, _found=True)
245
248
 
246
249
    def cloning_metadir(self, stacked=False):
260
263
 
261
264
 
262
265
def register_dummy_foreign_for_test(testcase):
263
 
    controldir.ControlDirFormat.register_format(DummyForeignVcsDirFormat)
264
 
    testcase.addCleanup(controldir.ControlDirFormat.unregister_format,
 
266
    bzrdir.BzrDirFormat.register_control_format(DummyForeignVcsDirFormat)
 
267
    testcase.addCleanup(bzrdir.BzrDirFormat.unregister_control_format,
265
268
                        DummyForeignVcsDirFormat)
266
 
    controldir.ControlDirFormat.register_prober(DummyForeignProber)
267
 
    testcase.addCleanup(controldir.ControlDirFormat.unregister_prober,
268
 
        DummyForeignProber)
269
269
    # We need to register the optimiser to make the dummy appears really
270
270
    # different from a regular bzr repository.
271
271
    branch.InterBranch.register_optimiser(InterToDummyVcsBranch)
273
273
                        InterToDummyVcsBranch)
274
274
 
275
275
 
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
276
class ForeignVcsRegistryTests(tests.TestCase):
287
277
    """Tests for the ForeignVcsRegistry class."""
288
278