/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/smart.py

Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
196
196
 
197
197
from cStringIO import StringIO
198
198
import os
199
 
import select
200
199
import socket
201
200
import tempfile
202
201
import threading
212
211
    urlutils,
213
212
    )
214
213
from bzrlib.bundle.serializer import write_bundle
 
214
try:
 
215
    from bzrlib.transport import ssh
 
216
except errors.ParamikoNotPresent:
 
217
    # no paramiko.  SmartSSHClientMedium will break.
 
218
    pass
215
219
 
216
220
# must do this otherwise urllib can't parse the urls properly :(
217
221
for scheme in ['ssh', 'bzr', 'bzr+loopback', 'bzr+ssh']:
884
888
    """
885
889
 
886
890
    def __init__(self):
887
 
        self._homedir = os.getcwd()
 
891
        self._homedir = urlutils.local_path_to_url(os.getcwd())[7:]
888
892
        # The server is set up by default like for ssh access: the client
889
893
        # passes filesystem-absolute paths; therefore the server must look
890
894
        # them up relative to the root directory.  it might be better to act
891
895
        # a public server and have the server rewrite paths into the test
892
896
        # directory.
893
 
        SmartTCPServer.__init__(self, transport.get_transport("file:///"))
 
897
        SmartTCPServer.__init__(self,
 
898
            transport.get_transport(urlutils.local_path_to_url('/')))
894
899
        
895
900
    def setUp(self):
896
901
        """Set up server for testing"""
902
907
    def get_url(self):
903
908
        """Return the url of the server"""
904
909
        host, port = self._server_socket.getsockname()
905
 
        # XXX: I think this is likely to break on windows -- self._homedir will
906
 
        # have backslashes (and maybe a drive letter?).
907
 
        #  -- Andrew Bennetts, 2006-08-29
908
910
        return "bzr://%s:%d%s" % (host, port, urlutils.escape(self._homedir))
909
911
 
910
912
    def get_bogus_url(self):
1743
1745
        super(SmartTCPTransport, self).__init__(url, medium=medium)
1744
1746
 
1745
1747
 
1746
 
try:
1747
 
    from bzrlib.transport import ssh
1748
 
except errors.ParamikoNotPresent:
1749
 
    # no paramiko, no SSHTransport.
1750
 
    pass
1751
 
else:
1752
 
    class SmartSSHTransport(SmartTransport):
1753
 
        """Connection to smart server over SSH.
1754
 
 
1755
 
        This is essentially just a factory to get 'RemoteTransport(url,
1756
 
            SmartSSHClientMedium).
1757
 
        """
1758
 
 
1759
 
        def __init__(self, url):
1760
 
            _scheme, _username, _password, _host, _port, _path = \
1761
 
                transport.split_url(url)
1762
 
            try:
1763
 
                if _port is not None:
1764
 
                    _port = int(_port)
1765
 
            except (ValueError, TypeError), e:
1766
 
                raise errors.InvalidURL(path=url, extra="invalid port %s" % 
1767
 
                    _port)
1768
 
            medium = SmartSSHClientMedium(_host, _port, _username, _password)
1769
 
            super(SmartSSHTransport, self).__init__(url, medium=medium)
 
1748
class SmartSSHTransport(SmartTransport):
 
1749
    """Connection to smart server over SSH.
 
1750
 
 
1751
    This is essentially just a factory to get 'RemoteTransport(url,
 
1752
        SmartSSHClientMedium).
 
1753
    """
 
1754
 
 
1755
    def __init__(self, url):
 
1756
        _scheme, _username, _password, _host, _port, _path = \
 
1757
            transport.split_url(url)
 
1758
        try:
 
1759
            if _port is not None:
 
1760
                _port = int(_port)
 
1761
        except (ValueError, TypeError), e:
 
1762
            raise errors.InvalidURL(path=url, extra="invalid port %s" % 
 
1763
                _port)
 
1764
        medium = SmartSSHClientMedium(_host, _port, _username, _password)
 
1765
        super(SmartSSHTransport, self).__init__(url, medium=medium)
1770
1766
 
1771
1767
 
1772
1768
def get_test_permutations():