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

« back to all changes in this revision

Viewing changes to bzrlib/transport/decorator.py

  • Committer: Martin Pool
  • Date: 2010-08-18 04:26:39 UTC
  • mfrom: (129.1.8 packaging-karmic)
  • Revision ID: mbp@sourcefrog.net-20100818042639-mjoxtngyjwiu05fo
* PPA rebuild for lucid.
* PPA rebuild for karmic.
* PPA rebuild onto jaunty.
* New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
stub functions to allow other decorators to be written easily.
21
21
"""
22
22
 
23
 
from bzrlib.transport import get_transport, Transport, Server
24
 
 
25
 
 
26
 
class TransportDecorator(Transport):
 
23
from bzrlib import transport
 
24
 
 
25
 
 
26
class TransportDecorator(transport.Transport):
27
27
    """A no-change decorator for Transports.
28
28
 
29
29
    Subclasses of this are new transports that are based on an
50
50
                             (url, prefix))
51
51
        not_decorated_url = url[len(prefix):]
52
52
        if _decorated is None:
53
 
            self._decorated = get_transport(not_decorated_url)
 
53
            self._decorated = transport.get_transport(not_decorated_url)
54
54
        else:
55
55
            self._decorated = _decorated
56
56
        super(TransportDecorator, self).__init__(prefix + self._decorated.base)
177
177
            return None
178
178
 
179
179
 
180
 
class DecoratorServer(Server):
181
 
    """Server for the TransportDecorator for testing with.
182
 
 
183
 
    To use this when subclassing TransportDecorator, override override the
184
 
    get_decorator_class method.
185
 
    """
186
 
 
187
 
    def start_server(self, server=None):
188
 
        """See bzrlib.transport.Server.start_server.
189
 
 
190
 
        :server: decorate the urls given by server. If not provided a
191
 
        LocalServer is created.
192
 
        """
193
 
        if server is not None:
194
 
            self._made_server = False
195
 
            self._server = server
196
 
        else:
197
 
            from bzrlib.transport.local import LocalURLServer
198
 
            self._made_server = True
199
 
            self._server = LocalURLServer()
200
 
            self._server.start_server()
201
 
 
202
 
    def stop_server(self):
203
 
        if self._made_server:
204
 
            self._server.stop_server()
205
 
 
206
 
    def get_decorator_class(self):
207
 
        """Return the class of the decorators we should be constructing."""
208
 
        raise NotImplementedError(self.get_decorator_class)
209
 
 
210
 
    def get_url_prefix(self):
211
 
        """What URL prefix does this decorator produce?"""
212
 
        return self.get_decorator_class()._get_url_prefix()
213
 
 
214
 
    def get_bogus_url(self):
215
 
        """See bzrlib.transport.Server.get_bogus_url."""
216
 
        return self.get_url_prefix() + self._server.get_bogus_url()
217
 
 
218
 
    def get_url(self):
219
 
        """See bzrlib.transport.Server.get_url."""
220
 
        return self.get_url_prefix() + self._server.get_url()
221
 
 
222
 
 
223
180
def get_test_permutations():
224
181
    """Return the permutations to be used in testing.
225
182