~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/sftp.py

  • Committer: Olaf Conradi
  • Date: 2006-05-15 22:54:09 UTC
  • mto: (1668.1.14 bzr-0.8.mbp)
  • mto: This revision was merged to the branch mainline in revision 1710.
  • Revision ID: olaf@conradi.org-20060515225409-071211ddf818569a
Fix bug in knits when raising InvalidRevisionId without the required
number of arguments. Fixes #44284.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
from bzrlib.transport import (
45
45
    register_urlparse_netloc_protocol,
46
46
    Server,
47
 
    split_url,
48
47
    Transport,
49
48
    urlescape,
50
49
    )
663
662
        return urlparse.urlunparse(('sftp', netloc, path, '', '', ''))
664
663
 
665
664
    def _split_url(self, url):
666
 
        (scheme, username, password, host, port, path) = split_url(url)
 
665
        if isinstance(url, unicode):
 
666
            url = url.encode('utf-8')
 
667
        (scheme, netloc, path, params,
 
668
         query, fragment) = urlparse.urlparse(url, allow_fragments=False)
667
669
        assert scheme == 'sftp'
 
670
        username = password = host = port = None
 
671
        if '@' in netloc:
 
672
            username, host = netloc.split('@', 1)
 
673
            if ':' in username:
 
674
                username, password = username.split(':', 1)
 
675
                password = urllib.unquote(password)
 
676
            username = urllib.unquote(username)
 
677
        else:
 
678
            host = netloc
 
679
 
 
680
        if ':' in host:
 
681
            host, port = host.rsplit(':', 1)
 
682
            try:
 
683
                port = int(port)
 
684
            except ValueError:
 
685
                # TODO: Should this be ConnectionError?
 
686
                raise TransportError('%s: invalid port number' % port)
 
687
        host = urllib.unquote(host)
 
688
 
 
689
        path = urllib.unquote(path)
668
690
 
669
691
        # the initial slash should be removed from the path, and treated
670
692
        # as a homedir relative path (the path begins with a double slash
997
1019
                return '1'
998
1020
            def get_hexdump(self):
999
1021
                return False
1000
 
            def close(self):
1001
 
                pass
1002
1022
 
1003
1023
        server = paramiko.SFTPServer(FakeChannel(), 'sftp', StubServer(self), StubSFTPServer,
1004
1024
                                     root=self._root, home=self._server_homedir)