/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 bzrlib/smart/vfs.py

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

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
 
from ... import urlutils
33
 
from . import request
 
31
from bzrlib import errors
 
32
from bzrlib import urlutils
 
33
from bzrlib.smart import request
34
34
 
35
35
 
36
36
def _deserialise_optional_mode(mode):
45
45
def vfs_enabled():
46
46
    """Is the VFS enabled ?
47
47
 
48
 
    the VFS is disabled when the BRZ_NO_SMART_VFS environment variable is set.
 
48
    the VFS is disabled when the BZR_NO_SMART_VFS environment variable is set.
49
49
 
50
50
    :return: True if it is enabled.
51
51
    """
52
 
    return not 'BRZ_NO_SMART_VFS' in os.environ
 
52
    return not 'BZR_NO_SMART_VFS' in os.environ
53
53
 
54
54
 
55
55
class VfsRequest(request.SmartServerRequest):
60
60
 
61
61
    def _check_enabled(self):
62
62
        if not vfs_enabled():
63
 
            raise request.DisabledMethod(self.__class__.__name__)
 
63
            raise errors.DisabledMethod(self.__class__.__name__)
64
64
 
65
65
    def translate_client_path(self, relpath):
66
66
        # VFS requests are made with escaped paths so the escaping done in
187
187
    def do_body(self, body_bytes):
188
188
        """accept offsets for a readv request."""
189
189
        offsets = self._deserialise_offsets(body_bytes)
190
 
        backing_bytes = b''.join(bytes for offset, bytes in
 
190
        backing_bytes = ''.join(bytes for offset, bytes in
191
191
            self._backing_transport.readv(self._relpath, offsets))
192
 
        return request.SuccessfulSmartServerResponse((b'readv',), backing_bytes)
 
192
        return request.SuccessfulSmartServerResponse(('readv',), backing_bytes)
193
193
 
194
194
    def _deserialise_offsets(self, text):
195
195
        # XXX: FIXME this should be on the protocol object.
196
196
        offsets = []
197
 
        for line in text.split(b'\n'):
 
197
        for line in text.split('\n'):
198
198
            if not line:
199
199
                continue
200
 
            start, length = line.split(b',')
 
200
            start, length = line.split(',')
201
201
            offsets.append((int(start), int(length)))
202
202
        return offsets
203
203