~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/sftp.py

  • Committer: Vincent Ladeuil
  • Date: 2011-10-27 15:38:14 UTC
  • mfrom: (6015.44.4 2.4)
  • mto: This revision was merged to the branch mainline in revision 6236.
  • Revision ID: v.ladeuil+lp@free.fr-20111027153814-0r4nd2io1jv6t47f
Merge 2.4 into trunk including fix for bug #880701

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
import stat
32
32
import sys
33
33
import time
34
 
import urllib
35
 
import urlparse
36
34
import warnings
37
35
 
38
36
from bzrlib import (
42
40
    urlutils,
43
41
    )
44
42
from bzrlib.errors import (FileExists,
45
 
                           NoSuchFile, PathNotChild,
 
43
                           NoSuchFile,
46
44
                           TransportError,
47
45
                           LockError,
48
46
                           PathError,
49
47
                           ParamikoNotPresent,
50
48
                           )
51
 
from bzrlib.osutils import pathjoin, fancy_rename, getcwd
52
 
from bzrlib.symbol_versioning import (
53
 
        deprecated_function,
54
 
        )
 
49
from bzrlib.osutils import fancy_rename
55
50
from bzrlib.trace import mutter, warning
56
51
from bzrlib.transport import (
57
52
    FileFileStream,
58
53
    _file_streams,
59
 
    local,
60
 
    Server,
61
54
    ssh,
62
55
    ConnectedTransport,
63
56
    )
337
330
    # up the request itself, rather than us having to worry about it
338
331
    _max_request_size = 32768
339
332
 
340
 
    def __init__(self, base, _from_transport=None):
341
 
        super(SFTPTransport, self).__init__(base,
342
 
                                            _from_transport=_from_transport)
343
 
 
344
333
    def _remote_path(self, relpath):
345
334
        """Return the path to be passed along the sftp protocol for relpath.
346
335
 
347
336
        :param relpath: is a urlencoded string.
348
337
        """
349
 
        relative = urlutils.unescape(relpath).encode('utf-8')
350
 
        remote_path = self._combine_paths(self._path, relative)
 
338
        remote_path = self._parsed_url.clone(relpath).path
351
339
        # the initial slash should be removed from the path, and treated as a
352
340
        # homedir relative path (the path begins with a double slash if it is
353
341
        # absolute).  see draft-ietf-secsh-scp-sftp-ssh-uri-03.txt
372
360
        in base url at transport creation time.
373
361
        """
374
362
        if credentials is None:
375
 
            password = self._password
 
363
            password = self._parsed_url.password
376
364
        else:
377
365
            password = credentials
378
366
 
379
367
        vendor = ssh._get_ssh_vendor()
380
 
        user = self._user
 
368
        user = self._parsed_url.user
381
369
        if user is None:
382
370
            auth = config.AuthenticationConfig()
383
 
            user = auth.get_user('ssh', self._host, self._port)
384
 
        connection = vendor.connect_sftp(self._user, password,
385
 
                                         self._host, self._port)
 
371
            user = auth.get_user('ssh', self._parsed_url.host,
 
372
                self._parsed_url.port)
 
373
        connection = vendor.connect_sftp(self._parsed_url.user, password,
 
374
            self._parsed_url.host, self._parsed_url.port)
386
375
        return connection, (user, password)
387
376
 
388
377
    def disconnect(self):