~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/remote.py

  • Committer: Patch Queue Manager
  • Date: 2014-10-06 16:32:42 UTC
  • mfrom: (6597.2.4 split-diff-tests)
  • Revision ID: pqm@pqm.ubuntu.com-20141006163242-c2cll01cwc24grkk
(vila) Split some tests to be able to get finer grained failures (Vincent
 Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2012, 2016 Canonical Ltd
 
1
# Copyright (C) 2006-2010 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
247
247
        transport._file_streams[self.abspath(relpath)] = result
248
248
        return result
249
249
 
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',
 
250
    def put_bytes(self, relpath, upload_contents, mode=None):
 
251
        # FIXME: upload_file is probably not safe for non-ascii characters -
 
252
        # should probably just pass all parameters as length-delimited
 
253
        # strings?
 
254
        if type(upload_contents) is unicode:
 
255
            # Although not strictly correct, we raise UnicodeEncodeError to be
 
256
            # compatible with other transports.
 
257
            raise UnicodeEncodeError(
 
258
                'undefined', upload_contents, 0, 1,
 
259
                'put_bytes must be given bytes, not unicode.')
 
260
        resp = self._call_with_body_bytes('put',
256
261
            (self._remote_path(relpath), self._serialise_optional_mode(mode)),
257
 
            raw_bytes)
 
262
            upload_contents)
258
263
        self._ensure_ok(resp)
259
 
        return len(raw_bytes)
 
264
        return len(upload_contents)
260
265
 
261
 
    def put_bytes_non_atomic(self, relpath, raw_bytes, mode=None,
 
266
    def put_bytes_non_atomic(self, relpath, bytes, mode=None,
262
267
                             create_parent_dir=False,
263
268
                             dir_mode=None):
264
269
        """See Transport.put_bytes_non_atomic."""
271
276
            'put_non_atomic',
272
277
            (self._remote_path(relpath), self._serialise_optional_mode(mode),
273
278
             create_parent_str, self._serialise_optional_mode(dir_mode)),
274
 
            raw_bytes)
 
279
            bytes)
275
280
        self._ensure_ok(resp)
276
281
 
277
282
    def put_file(self, relpath, upload_file, mode=None):