/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/bzr/smart/vfs.py

  • Committer: Jelmer Vernooij
  • Date: 2019-03-04 00:16:27 UTC
  • mfrom: (7293 work)
  • mto: This revision was merged to the branch mainline in revision 7318.
  • Revision ID: jelmer@jelmer.uk-20190304001627-v6u7o6pf97tukhek
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
import os
30
30
 
31
 
from ... import errors
32
31
from ... import urlutils
33
32
from . import request
34
33
 
47
46
 
48
47
    the VFS is disabled when the BRZ_NO_SMART_VFS environment variable is set.
49
48
 
50
 
    :return: True if it is enabled.
 
49
    :return: ``True`` if it is enabled.
51
50
    """
52
 
    return not 'BRZ_NO_SMART_VFS' in os.environ
 
51
    return 'BRZ_NO_SMART_VFS' not in os.environ
53
52
 
54
53
 
55
54
class VfsRequest(request.SmartServerRequest):
155
154
        self._mode = _deserialise_optional_mode(mode)
156
155
 
157
156
    def do_body(self, body_bytes):
158
 
        self._backing_transport.put_bytes(self._relpath, body_bytes, self._mode)
 
157
        self._backing_transport.put_bytes(
 
158
            self._relpath, body_bytes, self._mode)
159
159
        return request.SuccessfulSmartServerResponse((b'ok',))
160
160
 
161
161
 
171
171
 
172
172
    def do_body(self, body_bytes):
173
173
        self._backing_transport.put_bytes_non_atomic(self._relpath,
174
 
                body_bytes,
175
 
                mode=self._mode,
176
 
                create_parent_dir=self._create_parent,
177
 
                dir_mode=self._dir_mode)
 
174
                                                     body_bytes,
 
175
                                                     mode=self._mode,
 
176
                                                     create_parent_dir=self._create_parent,
 
177
                                                     dir_mode=self._dir_mode)
178
178
        return request.SuccessfulSmartServerResponse((b'ok',))
179
179
 
180
180
 
188
188
        """accept offsets for a readv request."""
189
189
        offsets = self._deserialise_offsets(body_bytes)
190
190
        backing_bytes = b''.join(bytes for offset, bytes in
191
 
            self._backing_transport.readv(self._relpath, offsets))
 
191
                                 self._backing_transport.readv(self._relpath, offsets))
192
192
        return request.SuccessfulSmartServerResponse((b'readv',), backing_bytes)
193
193
 
194
194
    def _deserialise_offsets(self, text):
228
228
        stat = self._backing_transport.stat(relpath)
229
229
        return request.SuccessfulSmartServerResponse(
230
230
            (b'stat', str(stat.st_size).encode('ascii'), oct(stat.st_mode).encode('ascii')))
231