/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/transport/remote.py

MergeĀ rename-SmartTransportĀ branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
imported from bzrlib.smart.
21
21
"""
22
22
 
23
 
__all__ = ['RemoteTransport', 'SmartTCPTransport', 'SmartSSHTransport']
 
23
__all__ = ['RemoteTransport', 'RemoteTCPTransport', 'RemoteSSHTransport']
24
24
 
25
25
from cStringIO import StringIO
26
26
import urllib
63
63
 
64
64
    The connection can be made over a tcp socket, an ssh pipe or a series of
65
65
    http requests.  There are concrete subclasses for each type:
66
 
    SmartTCPTransport, etc.
 
66
    RemoteTCPTransport, etc.
67
67
    """
68
68
 
69
69
    # IMPORTANT FOR IMPLEMENTORS: RemoteTransport MUST NOT be given encoding
417
417
            self._translate_error(resp)
418
418
 
419
419
 
420
 
class SmartTCPTransport(RemoteTransport):
 
420
class RemoteTCPTransport(RemoteTransport):
421
421
    """Connection to smart server over plain tcp.
422
422
    
423
423
    This is essentially just a factory to get 'RemoteTransport(url,
436
436
                raise errors.InvalidURL(
437
437
                    path=url, extra="invalid port %s" % _port)
438
438
        client_medium = medium.SmartTCPClientMedium(_host, _port)
439
 
        super(SmartTCPTransport, self).__init__(url, medium=client_medium)
440
 
 
441
 
 
442
 
class SmartSSHTransport(RemoteTransport):
 
439
        super(RemoteTCPTransport, self).__init__(url, medium=client_medium)
 
440
 
 
441
 
 
442
class RemoteSSHTransport(RemoteTransport):
443
443
    """Connection to smart server over SSH.
444
444
 
445
445
    This is essentially just a factory to get 'RemoteTransport(url,
457
457
                _port)
458
458
        client_medium = medium.SmartSSHClientMedium(_host, _port,
459
459
                                                    _username, _password)
460
 
        super(SmartSSHTransport, self).__init__(url, medium=client_medium)
461
 
 
462
 
 
463
 
class SmartHTTPTransport(RemoteTransport):
 
460
        super(RemoteSSHTransport, self).__init__(url, medium=client_medium)
 
461
 
 
462
 
 
463
class RemoteHTTPTransport(RemoteTransport):
464
464
    """Just a way to connect between a bzr+http:// url and http://.
465
465
    
466
 
    This connection operates slightly differently than the SmartSSHTransport.
 
466
    This connection operates slightly differently than the RemoteSSHTransport.
467
467
    It uses a plain http:// transport underneath, which defines what remote
468
468
    .bzr/smart URL we are connected to. From there, all paths that are sent are
469
469
    sent as relative paths, this way, the remote side can properly
480
480
        else:
481
481
            self._http_transport = http_transport
482
482
        http_medium = self._http_transport.get_smart_medium()
483
 
        super(SmartHTTPTransport, self).__init__(url, medium=http_medium)
 
483
        super(RemoteHTTPTransport, self).__init__(url, medium=http_medium)
484
484
 
485
485
    def _remote_path(self, relpath):
486
486
        """After connecting HTTP Transport only deals in relative URLs."""
498
498
        return self._unparse_url(self._combine_paths(self._path, relpath))
499
499
 
500
500
    def clone(self, relative_url):
501
 
        """Make a new SmartHTTPTransport related to me.
 
501
        """Make a new RemoteHTTPTransport related to me.
502
502
 
503
503
        This is re-implemented rather than using the default
504
 
        SmartTransport.clone() because we must be careful about the underlying
 
504
        RemoteTransport.clone() because we must be careful about the underlying
505
505
        http transport.
506
506
        """
507
507
        if relative_url:
511
511
        # By cloning the underlying http_transport, we are able to share the
512
512
        # connection.
513
513
        new_transport = self._http_transport.clone(relative_url)
514
 
        return SmartHTTPTransport(abs_url, http_transport=new_transport)
 
514
        return RemoteHTTPTransport(abs_url, http_transport=new_transport)
515
515
 
516
516
 
517
517
def get_test_permutations():
519
519
    ### We may need a little more test framework support to construct an
520
520
    ### appropriate RemoteTransport in the future.
521
521
    from bzrlib.smart import server
522
 
    return [(SmartTCPTransport, server.SmartTCPServer_for_testing)]
 
522
    return [(RemoteTCPTransport, server.SmartTCPServer_for_testing)]