~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_foreign.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-09-01 08:02:42 UTC
  • mfrom: (5390.3.3 faster-revert-593560)
  • Revision ID: pqm@pqm.ubuntu.com-20100901080242-esg62ody4frwmy66
(spiv) Avoid repeatedly calling self.target.all_file_ids() in
 InterTree.iter_changes. (Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008 Canonical Ltd
 
1
# Copyright (C) 2008, 2009, 2010 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,
90
91
        self._format = _format
91
92
        self._base = a_bzrdir.transport.base
92
93
        self._ignore_fallbacks = False
 
94
        self.bzrdir = a_bzrdir
93
95
        foreign.ForeignBranch.__init__(self, 
94
96
            DummyForeignVcsMapping(DummyForeignVcs()))
95
97
        branch.BzrBranch6.__init__(self, _format, _control_files, a_bzrdir, 
171
173
        super(DummyForeignVcsBranchFormat, self).__init__()
172
174
        self._matchingbzrdir = DummyForeignVcsDirFormat()
173
175
 
174
 
    def open(self, a_bzrdir, _found=False):
 
176
    def open(self, a_bzrdir, name=None, _found=False):
175
177
        if not _found:
176
178
            raise NotImplementedError
177
179
        try:
178
 
            transport = a_bzrdir.get_branch_transport(None)
 
180
            transport = a_bzrdir.get_branch_transport(None, name=name)
179
181
            control_files = lockable_files.LockableFiles(transport, 'lock',
180
182
                                                         lockdir.LockDir)
181
183
            return DummyForeignVcsBranch(_format=self,
204
206
    def get_branch_format(self):
205
207
        return DummyForeignVcsBranchFormat()
206
208
 
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
 
 
214
209
    def initialize_on_transport(self, transport):
215
210
        """Initialize a new bzrdir in the base directory of a Transport."""
216
211
        # Since we don't have a .bzr directory, inherit the
243
238
        self._control_files = lockable_files.LockableFiles(self.transport,
244
239
            "lock", lockable_files.TransportLock)
245
240
 
246
 
    def open_branch(self, ignore_fallbacks=True):
 
241
    def open_branch(self, name=None, unsupported=False, ignore_fallbacks=True):
 
242
        if name is not None:
 
243
            raise errors.NoColocatedBranchSupport(self)
247
244
        return self._format.get_branch_format().open(self, _found=True)
248
245
 
249
246
    def cloning_metadir(self, stacked=False):
263
260
 
264
261
 
265
262
def register_dummy_foreign_for_test(testcase):
266
 
    bzrdir.BzrDirFormat.register_control_format(DummyForeignVcsDirFormat)
267
 
    testcase.addCleanup(bzrdir.BzrDirFormat.unregister_control_format,
 
263
    controldir.ControlDirFormat.register_format(DummyForeignVcsDirFormat)
 
264
    testcase.addCleanup(controldir.ControlDirFormat.unregister_format,
268
265
                        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
 
276
286
class ForeignVcsRegistryTests(tests.TestCase):
277
287
    """Tests for the ForeignVcsRegistry class."""
278
288