~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/remote.py

  • Committer: Vincent Ladeuil
  • Date: 2017-01-17 15:27:00 UTC
  • mfrom: (6619.2.1 1622039-diff-binaries)
  • mto: This revision was merged to the branch mainline in revision 6620.
  • Revision ID: v.ladeuil+lp@free.fr-20170117152700-d0l1z87gbbrlwdix
Merge bugfix for #1622039

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006-2012, 2016 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
36
36
    urlutils,
37
37
    )
38
38
from bzrlib.smart import client, medium
39
 
from bzrlib.symbol_versioning import (
40
 
    deprecated_method,
41
 
    )
42
39
 
43
40
 
44
41
class _SmartStat(object):
250
247
        transport._file_streams[self.abspath(relpath)] = result
251
248
        return result
252
249
 
253
 
    def put_bytes(self, relpath, upload_contents, mode=None):
254
 
        # FIXME: upload_file is probably not safe for non-ascii characters -
255
 
        # should probably just pass all parameters as length-delimited
256
 
        # strings?
257
 
        if type(upload_contents) is unicode:
258
 
            # Although not strictly correct, we raise UnicodeEncodeError to be
259
 
            # compatible with other transports.
260
 
            raise UnicodeEncodeError(
261
 
                'undefined', upload_contents, 0, 1,
262
 
                'put_bytes must be given bytes, not unicode.')
263
 
        resp = self._call_with_body_bytes('put',
 
250
    def put_bytes(self, relpath, raw_bytes, mode=None):
 
251
        if not isinstance(raw_bytes, str):
 
252
            raise TypeError(
 
253
                'raw_bytes must be a plain string, not %s' % type(raw_bytes))
 
254
        resp = self._call_with_body_bytes(
 
255
            'put',
264
256
            (self._remote_path(relpath), self._serialise_optional_mode(mode)),
265
 
            upload_contents)
 
257
            raw_bytes)
266
258
        self._ensure_ok(resp)
267
 
        return len(upload_contents)
 
259
        return len(raw_bytes)
268
260
 
269
 
    def put_bytes_non_atomic(self, relpath, bytes, mode=None,
 
261
    def put_bytes_non_atomic(self, relpath, raw_bytes, mode=None,
270
262
                             create_parent_dir=False,
271
263
                             dir_mode=None):
272
264
        """See Transport.put_bytes_non_atomic."""
279
271
            'put_non_atomic',
280
272
            (self._remote_path(relpath), self._serialise_optional_mode(mode),
281
273
             create_parent_str, self._serialise_optional_mode(dir_mode)),
282
 
            bytes)
 
274
            raw_bytes)
283
275
        self._ensure_ok(resp)
284
276
 
285
277
    def put_file(self, relpath, upload_file, mode=None):