~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/sftp.py

  • Committer: Martin von Gagern
  • Date: 2011-06-01 12:53:56 UTC
  • mto: This revision was merged to the branch mainline in revision 6009.
  • Revision ID: martin.vgagern@gmx.net-20110601125356-lwozv2vecea6hxfz
Change from no_decorate to classify as name for the argument.

The command line switch remains as --no-classify, to keep backwards
compatibility.  Users are free to include --no-classify in an alias, and
still use --classify to change back.

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
34
36
import warnings
35
37
 
36
38
from bzrlib import (
40
42
    urlutils,
41
43
    )
42
44
from bzrlib.errors import (FileExists,
43
 
                           NoSuchFile,
 
45
                           NoSuchFile, PathNotChild,
44
46
                           TransportError,
45
47
                           LockError,
46
48
                           PathError,
47
49
                           ParamikoNotPresent,
48
50
                           )
49
 
from bzrlib.osutils import fancy_rename
 
51
from bzrlib.osutils import pathjoin, fancy_rename, getcwd
 
52
from bzrlib.symbol_versioning import (
 
53
        deprecated_function,
 
54
        )
50
55
from bzrlib.trace import mutter, warning
51
56
from bzrlib.transport import (
52
57
    FileFileStream,
53
58
    _file_streams,
 
59
    local,
 
60
    Server,
54
61
    ssh,
55
62
    ConnectedTransport,
56
63
    )
107
114
        except FileExists:
108
115
            raise LockError('File %r already locked' % (self.path,))
109
116
 
 
117
    def __del__(self):
 
118
        """Should this warn, or actually try to cleanup?"""
 
119
        if self.lock_file:
 
120
            warning("SFTPLock %r not explicitly unlocked" % (self.path,))
 
121
            self.unlock()
 
122
 
110
123
    def unlock(self):
111
124
        if not self.lock_file:
112
125
            return
330
343
    # up the request itself, rather than us having to worry about it
331
344
    _max_request_size = 32768
332
345
 
 
346
    def __init__(self, base, _from_transport=None):
 
347
        super(SFTPTransport, self).__init__(base,
 
348
                                            _from_transport=_from_transport)
 
349
 
333
350
    def _remote_path(self, relpath):
334
351
        """Return the path to be passed along the sftp protocol for relpath.
335
352
 
336
353
        :param relpath: is a urlencoded string.
337
354
        """
338
 
        remote_path = self._parsed_url.clone(relpath).path
 
355
        relative = urlutils.unescape(relpath).encode('utf-8')
 
356
        remote_path = self._combine_paths(self._path, relative)
339
357
        # the initial slash should be removed from the path, and treated as a
340
358
        # homedir relative path (the path begins with a double slash if it is
341
359
        # absolute).  see draft-ietf-secsh-scp-sftp-ssh-uri-03.txt
360
378
        in base url at transport creation time.
361
379
        """
362
380
        if credentials is None:
363
 
            password = self._parsed_url.password
 
381
            password = self._password
364
382
        else:
365
383
            password = credentials
366
384
 
367
385
        vendor = ssh._get_ssh_vendor()
368
 
        user = self._parsed_url.user
 
386
        user = self._user
369
387
        if user is None:
370
388
            auth = config.AuthenticationConfig()
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)
 
389
            user = auth.get_user('ssh', self._host, self._port)
 
390
        connection = vendor.connect_sftp(self._user, password,
 
391
                                         self._host, self._port)
375
392
        return connection, (user, password)
376
393
 
377
394
    def disconnect(self):