~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/sftp.py

Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
from bzrlib.osutils import pathjoin, fancy_rename, getcwd
51
51
from bzrlib.symbol_versioning import (
52
52
        deprecated_function,
53
 
        zero_ninety,
54
53
        )
55
54
from bzrlib.trace import mutter, warning
56
55
from bzrlib.transport import (
92
91
_default_do_prefetch = (_paramiko_version >= (1, 5, 5))
93
92
 
94
93
 
95
 
@deprecated_function(zero_ninety)
96
 
def clear_connection_cache():
97
 
    """Remove all hosts from the SFTP connection cache.
98
 
 
99
 
    Primarily useful for test cases wanting to force garbage collection.
100
 
    We don't have a global connection cache anymore.
101
 
    """
102
 
 
103
94
class SFTPLock(object):
104
95
    """This fakes a lock in a remote location.
105
96
    
111
102
    __slots__ = ['path', 'lock_path', 'lock_file', 'transport']
112
103
 
113
104
    def __init__(self, path, transport):
114
 
        assert isinstance(transport, SFTPTransport)
115
 
 
116
105
        self.lock_file = None
117
106
        self.path = path
118
107
        self.lock_path = path + '.write-lock'
164
153
    _max_request_size = 32768
165
154
 
166
155
    def __init__(self, base, _from_transport=None):
167
 
        assert base.startswith('sftp://')
168
156
        super(SFTPTransport, self).__init__(base,
169
157
                                            _from_transport=_from_transport)
170
158
 
346
334
 
347
335
            if cur_data_len < cur_coalesced.length:
348
336
                continue
349
 
            assert cur_data_len == cur_coalesced.length, \
350
 
                "Somehow we read too much: %s != %s" % (cur_data_len,
351
 
                                                        cur_coalesced.length)
 
337
            if cur_data_len != cur_coalesced.length:
 
338
                raise AssertionError(
 
339
                    "Somehow we read too much: %s != %s" 
 
340
                    % (cur_data_len, cur_coalesced.length))
352
341
            all_data = ''.join(cur_data)
353
342
            cur_data = []
354
343
            cur_data_len = 0
948
937
    def setUp(self, backing_server=None):
949
938
        # XXX: TODO: make sftpserver back onto backing_server rather than local
950
939
        # disk.
951
 
        assert (backing_server is None or
952
 
                isinstance(backing_server, local.LocalURLServer)), (
953
 
            "backing_server should not be %r, because this can only serve the "
954
 
            "local current working directory." % (backing_server,))
 
940
        if not (backing_server is None or
 
941
                isinstance(backing_server, local.LocalURLServer)):
 
942
            raise AssertionError(
 
943
                "backing_server should not be %r, because this can only serve the "
 
944
                "local current working directory." % (backing_server,))
955
945
        self._original_vendor = ssh._ssh_vendor_manager._cached_ssh_vendor
956
946
        ssh._ssh_vendor_manager._cached_ssh_vendor = self._vendor
957
947
        if sys.platform == 'win32':