~bzr/ubuntu/lucid/bzr/beta-ppa

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_foreign.py

  • Committer: Max Bowsher
  • Date: 2011-02-09 04:08:25 UTC
  • mfrom: (0.5074.6 lucid)
  • Revision ID: maxb@f2s.com-20110209040825-7jqm4i78b8ojoy9z
Merge beta-ppa into ppa upon release of 2.3.0.

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