~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/request.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-10-06 20:45:48 UTC
  • mfrom: (4728.1.2 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20091006204548-bjnc3z4k256ppimz
MutableTree.has_changes() does not require a tree parameter anymore

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
            continue
70
70
        else:
71
71
            return
72
 
    raise errors.BzrError('jail break: %r' % (abspath,))
 
72
    raise errors.JailBreak(abspath)
73
73
 
74
74
 
75
75
_install_hook()
176
176
            return client_path
177
177
        if not client_path.startswith('/'):
178
178
            client_path = '/' + client_path
 
179
        if client_path + '/' == self._root_client_path:
 
180
            return '.'
179
181
        if client_path.startswith(self._root_client_path):
180
182
            path = client_path[len(self._root_client_path):]
181
183
            relpath = urlutils.joinpath('/', path)
279
281
 
280
282
    def accept_body(self, bytes):
281
283
        """Accept body data."""
 
284
        if self._command is None:
 
285
            # no active command object, so ignore the event.
 
286
            return
282
287
        self._run_handler_code(self._command.do_chunk, (bytes,), {})
283
288
 
284
289
    def end_of_body(self):
287
292
        # cannot read after this.
288
293
        self.finished_reading = True
289
294
 
290
 
    def dispatch_command(self, cmd, args):
291
 
        """Deprecated compatibility method.""" # XXX XXX
292
 
        try:
293
 
            command = self._commands.get(cmd)
294
 
        except LookupError:
295
 
            raise errors.UnknownSmartMethod(cmd)
296
 
        self._command = command(self._backing_transport, self._root_client_path)
297
 
        self._run_handler_code(self._command.execute, args, {})
298
 
 
299
295
    def _run_handler_code(self, callable, args, kwargs):
300
296
        """Run some handler specific code 'callable'.
301
297
 
338
334
            command = self._commands.get(cmd)
339
335
        except LookupError:
340
336
            raise errors.UnknownSmartMethod(cmd)
341
 
        self._command = command(self._backing_transport)
 
337
        self._command = command(
 
338
            self._backing_transport, self._root_client_path)
342
339
        self._run_handler_code(self._command.execute, args, {})
343
340
 
344
341
    def end_received(self):
 
342
        if self._command is None:
 
343
            # no active command object, so ignore the event.
 
344
            return
345
345
        self._run_handler_code(self._command.do_end, (), {})
346
346
 
347
347
    def post_body_error_received(self, error_args):
356
356
        return ('FileExists', err.path)
357
357
    elif isinstance(err, errors.DirectoryNotEmpty):
358
358
        return ('DirectoryNotEmpty', err.path)
 
359
    elif isinstance(err, errors.IncompatibleRepositories):
 
360
        return ('IncompatibleRepositories', str(err.source), str(err.target),
 
361
            str(err.details))
359
362
    elif isinstance(err, errors.ShortReadvError):
360
363
        return ('ShortReadvError', err.path, str(err.offset), str(err.length),
361
364
                str(err.actual))
390
393
    elif isinstance(err, errors.TokenMismatch):
391
394
        return ('TokenMismatch', err.given_token, err.lock_token)
392
395
    elif isinstance(err, errors.LockContention):
393
 
        return ('LockContention', err.lock, err.msg)
 
396
        return ('LockContention',)
394
397
    # Unserialisable error.  Log it, and return a generic error
395
398
    trace.log_exception_quietly()
396
399
    return ('error', str(err))
443
446
    'Branch.get_tags_bytes', 'bzrlib.smart.branch',
444
447
    'SmartServerBranchGetTagsBytes')
445
448
request_handlers.register_lazy(
 
449
    'Branch.set_tags_bytes', 'bzrlib.smart.branch',
 
450
    'SmartServerBranchSetTagsBytes')
 
451
request_handlers.register_lazy(
446
452
    'Branch.get_stacked_on_url', 'bzrlib.smart.branch', 'SmartServerBranchRequestGetStackedOnURL')
447
453
request_handlers.register_lazy(
448
454
    'Branch.last_revision_info', 'bzrlib.smart.branch', 'SmartServerBranchRequestLastRevisionInfo')
449
455
request_handlers.register_lazy(
450
456
    'Branch.lock_write', 'bzrlib.smart.branch', 'SmartServerBranchRequestLockWrite')
451
 
request_handlers.register_lazy(
452
 
    'Branch.revision_history', 'bzrlib.smart.branch', 'SmartServerRequestRevisionHistory')
453
 
request_handlers.register_lazy(
454
 
    'Branch.set_last_revision', 'bzrlib.smart.branch', 'SmartServerBranchRequestSetLastRevision')
 
457
request_handlers.register_lazy( 'Branch.revision_history',
 
458
    'bzrlib.smart.branch', 'SmartServerRequestRevisionHistory')
 
459
request_handlers.register_lazy( 'Branch.set_config_option',
 
460
    'bzrlib.smart.branch', 'SmartServerBranchRequestSetConfigOption')
 
461
request_handlers.register_lazy( 'Branch.set_last_revision',
 
462
    'bzrlib.smart.branch', 'SmartServerBranchRequestSetLastRevision')
455
463
request_handlers.register_lazy(
456
464
    'Branch.set_last_revision_info', 'bzrlib.smart.branch',
457
465
    'SmartServerBranchRequestSetLastRevisionInfo')
459
467
    'Branch.set_last_revision_ex', 'bzrlib.smart.branch',
460
468
    'SmartServerBranchRequestSetLastRevisionEx')
461
469
request_handlers.register_lazy(
 
470
    'Branch.set_parent_location', 'bzrlib.smart.branch',
 
471
    'SmartServerBranchRequestSetParentLocation')
 
472
request_handlers.register_lazy(
462
473
    'Branch.unlock', 'bzrlib.smart.branch', 'SmartServerBranchRequestUnlock')
463
474
request_handlers.register_lazy(
464
475
    'BzrDir.cloning_metadir', 'bzrlib.smart.bzrdir',
479
490
    'BzrDir.find_repositoryV3', 'bzrlib.smart.bzrdir',
480
491
    'SmartServerRequestFindRepositoryV3')
481
492
request_handlers.register_lazy(
 
493
    'BzrDir.get_config_file', 'bzrlib.smart.bzrdir',
 
494
    'SmartServerBzrDirRequestConfigFile')
 
495
request_handlers.register_lazy(
482
496
    'BzrDirFormat.initialize', 'bzrlib.smart.bzrdir',
483
497
    'SmartServerRequestInitializeBzrDir')
484
498
request_handlers.register_lazy(
 
499
    'BzrDirFormat.initialize_ex_1.16', 'bzrlib.smart.bzrdir',
 
500
    'SmartServerRequestBzrDirInitializeEx')
 
501
request_handlers.register_lazy(
 
502
    'BzrDir.open', 'bzrlib.smart.bzrdir', 'SmartServerRequestOpenBzrDir')
 
503
request_handlers.register_lazy(
 
504
    'BzrDir.open_2.1', 'bzrlib.smart.bzrdir', 'SmartServerRequestOpenBzrDir_2_1')
 
505
request_handlers.register_lazy(
485
506
    'BzrDir.open_branch', 'bzrlib.smart.bzrdir',
486
507
    'SmartServerRequestOpenBranch')
487
508
request_handlers.register_lazy(
529
550
request_handlers.register_lazy(
530
551
    'Repository.insert_stream', 'bzrlib.smart.repository', 'SmartServerRepositoryInsertStream')
531
552
request_handlers.register_lazy(
 
553
    'Repository.insert_stream_1.19', 'bzrlib.smart.repository', 'SmartServerRepositoryInsertStream_1_19')
 
554
request_handlers.register_lazy(
532
555
    'Repository.insert_stream_locked', 'bzrlib.smart.repository', 'SmartServerRepositoryInsertStreamLocked')
533
556
request_handlers.register_lazy(
534
557
    'Repository.is_shared', 'bzrlib.smart.repository', 'SmartServerRepositoryIsShared')
540
563
request_handlers.register_lazy(
541
564
    'Repository.unlock', 'bzrlib.smart.repository', 'SmartServerRepositoryUnlock')
542
565
request_handlers.register_lazy(
 
566
    'Repository.get_rev_id_for_revno', 'bzrlib.smart.repository',
 
567
    'SmartServerRepositoryGetRevIdForRevno')
 
568
request_handlers.register_lazy(
543
569
    'Repository.get_stream', 'bzrlib.smart.repository',
544
570
    'SmartServerRepositoryGetStream')
545
571
request_handlers.register_lazy(
 
572
    'Repository.get_stream_1.19', 'bzrlib.smart.repository',
 
573
    'SmartServerRepositoryGetStream_1_19')
 
574
request_handlers.register_lazy(
546
575
    'Repository.tarball', 'bzrlib.smart.repository',
547
576
    'SmartServerRepositoryTarball')
548
577
request_handlers.register_lazy(
551
580
    'stat', 'bzrlib.smart.vfs', 'StatRequest')
552
581
request_handlers.register_lazy(
553
582
    'Transport.is_readonly', 'bzrlib.smart.request', 'SmartServerIsReadonly')
554
 
request_handlers.register_lazy(
555
 
    'BzrDir.open', 'bzrlib.smart.bzrdir', 'SmartServerRequestOpenBzrDir')