/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: Mark Hammond
  • Date: 2008-12-21 07:42:20 UTC
  • mfrom: (3915 +trunk)
  • mto: (3932.3.1 cicp-1.11)
  • mto: This revision was merged to the branch mainline in revision 3937.
  • Revision ID: mhammond@skippinet.com.au-20081221074220-7dr5oydglxyyvic3
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
172
172
        try:
173
173
            return self._client.call(method, *args)
174
174
        except errors.ErrorFromSmartServer, err:
175
 
            self._translate_error(err)
 
175
            # The first argument, if present, is always a path.
 
176
            if args:
 
177
                context = {'relpath': args[0]}
 
178
            else:
 
179
                context = {}
 
180
            self._translate_error(err, **context)
176
181
 
177
182
    def _call_with_body_bytes(self, method, args, body):
178
183
        """Call a method on the remote server with body bytes."""
179
184
        try:
180
185
            return self._client.call_with_body_bytes(method, args, body)
181
186
        except errors.ErrorFromSmartServer, err:
182
 
            self._translate_error(err)
 
187
            # The first argument, if present, is always a path.
 
188
            if args:
 
189
                context = {'relpath': args[0]}
 
190
            else:
 
191
                context = {}
 
192
            self._translate_error(err, **context)
183
193
 
184
194
    def has(self, relpath):
185
195
        """Indicate whether a remote file of the given name exists or not.
313
323
        sorted_offsets = sorted(offsets)
314
324
        coalesced = list(self._coalesce_offsets(sorted_offsets,
315
325
                               limit=self._max_readv_combine,
316
 
                               fudge_factor=self._bytes_to_read_before_seek))
 
326
                               fudge_factor=self._bytes_to_read_before_seek,
 
327
                               max_size=self._max_readv_bytes))
317
328
 
318
329
        # now that we've coallesced things, avoid making enormous requests
319
330
        requests = []
347
358
                    [(c.start, c.length) for c in cur_request])
348
359
                resp, response_handler = result
349
360
            except errors.ErrorFromSmartServer, err:
350
 
                self._translate_error(err)
 
361
                self._translate_error(err, relpath)
351
362
 
352
363
            if resp[0] != 'readv':
353
364
                # This should raise an exception
411
422
        if resp[0] != 'ok':
412
423
            raise errors.UnexpectedSmartServerResponse(resp)
413
424
        
414
 
    def _translate_error(self, err, orig_path=None):
415
 
        remote._translate_error(err, path=orig_path)
 
425
    def _translate_error(self, err, relpath=None):
 
426
        remote._translate_error(err, path=relpath)
416
427
 
417
428
    def disconnect(self):
418
429
        self.get_smart_medium().disconnect()
557
568
                                   _from_transport=self,
558
569
                                   http_transport=self._http_transport)
559
570
 
 
571
    def _redirected_to(self, source, target):
 
572
        """See transport._redirected_to"""
 
573
        redirected = self._http_transport._redirected_to(source, target)
 
574
        if (redirected is not None
 
575
            and isinstance(redirected, type(self._http_transport))):
 
576
            return RemoteHTTPTransport('bzr+' + redirected.external_url(),
 
577
                                       http_transport=redirected)
 
578
        else:
 
579
            # Either None or a transport for a different protocol
 
580
            return redirected
 
581
 
560
582
 
561
583
def get_test_permutations():
562
584
    """Return (transport, server) permutations for testing."""