/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/transport/remote.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:
17
17
"""RemoteTransport client for the smart-server.
18
18
 
19
19
This module shouldn't be accessed directly.  The classes defined here should be
20
 
imported from breezy.bzr.smart.
 
20
imported from bzrlib.smart.
21
21
"""
22
22
 
23
23
from __future__ import absolute_import
24
24
 
25
25
__all__ = ['RemoteTransport', 'RemoteTCPTransport', 'RemoteSSHTransport']
26
26
 
27
 
from .. import (
 
27
from cStringIO import StringIO
 
28
 
 
29
from bzrlib import (
28
30
    config,
29
31
    debug,
30
32
    errors,
 
33
    remote,
31
34
    trace,
32
35
    transport,
33
36
    urlutils,
34
37
    )
35
 
from ..bzr import (
36
 
    remote,
37
 
    )
38
 
from ..sixish import (
39
 
    BytesIO,
40
 
    )
41
 
from ..bzr.smart import client, medium
 
38
from bzrlib.smart import client, medium
42
39
 
43
40
 
44
41
class _SmartStat(object):
182
179
        """Call a method on the remote server."""
183
180
        try:
184
181
            return self._client.call(method, *args)
185
 
        except errors.ErrorFromSmartServer as err:
 
182
        except errors.ErrorFromSmartServer, err:
186
183
            # The first argument, if present, is always a path.
187
184
            if args:
188
185
                context = {'relpath': args[0]}
194
191
        """Call a method on the remote server with body bytes."""
195
192
        try:
196
193
            return self._client.call_with_body_bytes(method, args, body)
197
 
        except errors.ErrorFromSmartServer as err:
 
194
        except errors.ErrorFromSmartServer, err:
198
195
            # The first argument, if present, is always a path.
199
196
            if args:
200
197
                context = {'relpath': args[0]}
220
217
 
221
218
        :see: Transport.get_bytes()/get_file()
222
219
        """
223
 
        return BytesIO(self.get_bytes(relpath))
 
220
        return StringIO(self.get_bytes(relpath))
224
221
 
225
222
    def get_bytes(self, relpath):
226
223
        remote = self._remote_path(relpath)
227
224
        try:
228
225
            resp, response_handler = self._client.call_expecting_body('get', remote)
229
 
        except errors.ErrorFromSmartServer as err:
 
226
        except errors.ErrorFromSmartServer, err:
230
227
            self._translate_error(err, relpath)
231
228
        if resp != ('ok', ):
232
229
            response_handler.cancel_read_body()
312
309
        self._ensure_ok(resp)
313
310
 
314
311
    def external_url(self):
315
 
        """See breezy.transport.Transport.external_url."""
 
312
        """See bzrlib.transport.Transport.external_url."""
316
313
        # the external path for RemoteTransports is the base
317
314
        return self.base
318
315
 
356
353
        # turn the list of offsets into a single stack to iterate
357
354
        offset_stack = iter(offsets)
358
355
        # using a list so it can be modified when passing down and coming back
359
 
        next_offset = [next(offset_stack)]
 
356
        next_offset = [offset_stack.next()]
360
357
        for cur_request in requests:
361
358
            try:
362
359
                result = self._client.call_with_body_readv_array(
363
360
                    ('readv', self._remote_path(relpath),),
364
361
                    [(c.start, c.length) for c in cur_request])
365
362
                resp, response_handler = result
366
 
            except errors.ErrorFromSmartServer as err:
 
363
            except errors.ErrorFromSmartServer, err:
367
364
                self._translate_error(err, relpath)
368
365
 
369
366
            if resp[0] != 'readv':
400
397
                #       not have a real string.
401
398
                if key == cur_offset_and_size:
402
399
                    yield cur_offset_and_size[0], this_data
403
 
                    cur_offset_and_size = next_offset[0] = next(offset_stack)
 
400
                    cur_offset_and_size = next_offset[0] = offset_stack.next()
404
401
                else:
405
402
                    data_map[key] = this_data
406
403
            data_offset += c_offset.length
409
406
            while cur_offset_and_size in data_map:
410
407
                this_data = data_map.pop(cur_offset_and_size)
411
408
                yield cur_offset_and_size[0], this_data
412
 
                cur_offset_and_size = next_offset[0] = next(offset_stack)
 
409
                cur_offset_and_size = next_offset[0] = offset_stack.next()
413
410
 
414
411
    def rename(self, rel_from, rel_to):
415
412
        self._call('rename',
602
599
    """Return (transport, server) permutations for testing."""
603
600
    ### We may need a little more test framework support to construct an
604
601
    ### appropriate RemoteTransport in the future.
605
 
    from ..tests import test_server
 
602
    from bzrlib.tests import test_server
606
603
    return [(RemoteTCPTransport, test_server.SmartTCPServer_for_testing)]