/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/request.py

  • Committer: Martin Pool
  • Date: 2011-11-29 00:50:36 UTC
  • mto: This revision was merged to the branch mainline in revision 6320.
  • Revision ID: mbp@canonical.com-20111129005036-1vopao4wm0yo9ekn
Slight cleanup of TimeoutFixture

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
# of a SmartServerRequest subclass.
32
32
 
33
33
 
34
 
import tempfile
35
 
import thread
36
34
import threading
37
35
 
38
36
from bzrlib import (
48
46
from bzrlib.lazy_import import lazy_import
49
47
lazy_import(globals(), """
50
48
from bzrlib.bundle import serializer
 
49
 
 
50
import tempfile
 
51
import thread
51
52
""")
52
53
 
53
54
 
134
135
        It will return a SmartServerResponse if the command does not expect a
135
136
        body.
136
137
 
137
 
        :param *args: the arguments of the request.
 
138
        :param args: the arguments of the request.
138
139
        """
139
140
        self._check_enabled()
140
141
        return self.do(*args)
414
415
    elif isinstance(err, errors.ShortReadvError):
415
416
        return ('ShortReadvError', err.path, str(err.offset), str(err.length),
416
417
                str(err.actual))
 
418
    elif isinstance(err, errors.RevisionNotPresent):
 
419
        return ('RevisionNotPresent', err.revision_id, err.file_id)
417
420
    elif isinstance(err, errors.UnstackableRepositoryFormat):
418
421
        return (('UnstackableRepositoryFormat', str(err.format), err.url))
419
422
    elif isinstance(err, errors.UnstackableBranchFormat):
420
423
        return ('UnstackableBranchFormat', str(err.format), err.url)
421
424
    elif isinstance(err, errors.NotStacked):
422
425
        return ('NotStacked',)
 
426
    elif isinstance(err, errors.BzrCheckError):
 
427
        return ('BzrCheckError', err.msg)
423
428
    elif isinstance(err, UnicodeError):
424
429
        # If it is a DecodeError, than most likely we are starting
425
430
        # with a plain string
446
451
        return ('TokenMismatch', err.given_token, err.lock_token)
447
452
    elif isinstance(err, errors.LockContention):
448
453
        return ('LockContention',)
 
454
    elif isinstance(err, MemoryError):
 
455
        # GZ 2011-02-24: Copy bzrlib.trace -Dmem_dump functionality here?
 
456
        return ('MemoryError',)
449
457
    # Unserialisable error.  Log it, and return a generic error
450
458
    trace.log_exception_quietly()
451
 
    return ('error', str(err))
 
459
    return ('error', trace._qualified_exception_name(err.__class__, True),
 
460
        str(err))
452
461
 
453
462
 
454
463
class HelloRequest(SmartServerRequest):
490
499
request_handlers.register_lazy(
491
500
    'append', 'bzrlib.smart.vfs', 'AppendRequest')
492
501
request_handlers.register_lazy(
 
502
    'Branch.break_lock', 'bzrlib.smart.branch',
 
503
    'SmartServerBranchBreakLock')
 
504
request_handlers.register_lazy(
493
505
    'Branch.get_config_file', 'bzrlib.smart.branch',
494
506
    'SmartServerBranchGetConfigFile')
495
507
request_handlers.register_lazy(
 
508
    'Branch.put_config_file', 'bzrlib.smart.branch',
 
509
    'SmartServerBranchPutConfigFile')
 
510
request_handlers.register_lazy(
496
511
    'Branch.get_parent', 'bzrlib.smart.branch', 'SmartServerBranchGetParent')
497
512
request_handlers.register_lazy(
498
513
    'Branch.get_tags_bytes', 'bzrlib.smart.branch',
501
516
    'Branch.set_tags_bytes', 'bzrlib.smart.branch',
502
517
    'SmartServerBranchSetTagsBytes')
503
518
request_handlers.register_lazy(
 
519
    'Branch.heads_to_fetch', 'bzrlib.smart.branch',
 
520
    'SmartServerBranchHeadsToFetch')
 
521
request_handlers.register_lazy(
504
522
    'Branch.get_stacked_on_url', 'bzrlib.smart.branch', 'SmartServerBranchRequestGetStackedOnURL')
505
523
request_handlers.register_lazy(
506
524
    'Branch.last_revision_info', 'bzrlib.smart.branch', 'SmartServerBranchRequestLastRevisionInfo')
507
525
request_handlers.register_lazy(
508
526
    'Branch.lock_write', 'bzrlib.smart.branch', 'SmartServerBranchRequestLockWrite')
 
527
request_handlers.register_lazy(
 
528
    'Branch.get_physical_lock_status', 'bzrlib.smart.branch',
 
529
    'SmartServerBranchRequestGetPhysicalLockStatus')
509
530
request_handlers.register_lazy( 'Branch.revision_history',
510
531
    'bzrlib.smart.branch', 'SmartServerRequestRevisionHistory')
511
532
request_handlers.register_lazy( 'Branch.set_config_option',
512
533
    'bzrlib.smart.branch', 'SmartServerBranchRequestSetConfigOption')
 
534
request_handlers.register_lazy( 'Branch.set_config_option_dict',
 
535
    'bzrlib.smart.branch', 'SmartServerBranchRequestSetConfigOptionDict')
513
536
request_handlers.register_lazy( 'Branch.set_last_revision',
514
537
    'bzrlib.smart.branch', 'SmartServerBranchRequestSetLastRevision')
515
538
request_handlers.register_lazy(
524
547
request_handlers.register_lazy(
525
548
    'Branch.unlock', 'bzrlib.smart.branch', 'SmartServerBranchRequestUnlock')
526
549
request_handlers.register_lazy(
 
550
    'Branch.revision_id_to_revno', 'bzrlib.smart.branch', 'SmartServerBranchRequestRevisionIdToRevno')
 
551
request_handlers.register_lazy(
527
552
    'BzrDir.cloning_metadir', 'bzrlib.smart.bzrdir',
528
553
    'SmartServerBzrDirRequestCloningMetaDir')
529
554
request_handlers.register_lazy(
545
570
    'BzrDir.get_config_file', 'bzrlib.smart.bzrdir',
546
571
    'SmartServerBzrDirRequestConfigFile')
547
572
request_handlers.register_lazy(
 
573
    'BzrDir.destroy_branch', 'bzrlib.smart.bzrdir',
 
574
    'SmartServerBzrDirRequestDestroyBranch')
 
575
request_handlers.register_lazy(
 
576
    'BzrDir.destroy_repository', 'bzrlib.smart.bzrdir',
 
577
    'SmartServerBzrDirRequestDestroyRepository')
 
578
request_handlers.register_lazy(
 
579
    'BzrDir.has_workingtree', 'bzrlib.smart.bzrdir',
 
580
    'SmartServerBzrDirRequestHasWorkingTree')
 
581
request_handlers.register_lazy(
548
582
    'BzrDirFormat.initialize', 'bzrlib.smart.bzrdir',
549
583
    'SmartServerRequestInitializeBzrDir')
550
584
request_handlers.register_lazy(
592
626
request_handlers.register_lazy(
593
627
    'PackRepository.autopack', 'bzrlib.smart.packrepository',
594
628
    'SmartServerPackRepositoryAutopack')
 
629
request_handlers.register_lazy('Repository.all_revision_ids',
 
630
                               'bzrlib.smart.repository',
 
631
                               'SmartServerRepositoryAllRevisionIds')
 
632
request_handlers.register_lazy('Repository.break_lock',
 
633
                               'bzrlib.smart.repository',
 
634
                               'SmartServerRepositoryBreakLock')
595
635
request_handlers.register_lazy('Repository.gather_stats',
596
636
                               'bzrlib.smart.repository',
597
637
                               'SmartServerRepositoryGatherStats')
599
639
                               'bzrlib.smart.repository',
600
640
                               'SmartServerRepositoryGetParentMap')
601
641
request_handlers.register_lazy(
 
642
    'Repository.add_signature_text', 'bzrlib.smart.repository',
 
643
    'SmartServerRepositoryAddSignatureText')
 
644
request_handlers.register_lazy(
602
645
    'Repository.get_revision_graph', 'bzrlib.smart.repository', 'SmartServerRepositoryGetRevisionGraph')
603
646
request_handlers.register_lazy(
 
647
    'Repository.get_revision_signature_text', 'bzrlib.smart.repository',
 
648
    'SmartServerRepositoryGetRevisionSignatureText')
 
649
request_handlers.register_lazy(
604
650
    'Repository.has_revision', 'bzrlib.smart.repository', 'SmartServerRequestHasRevision')
605
651
request_handlers.register_lazy(
 
652
    'Repository.has_signature_for_revision_id', 'bzrlib.smart.repository',
 
653
    'SmartServerRequestHasSignatureForRevisionId')
 
654
request_handlers.register_lazy(
606
655
    'Repository.insert_stream', 'bzrlib.smart.repository', 'SmartServerRepositoryInsertStream')
607
656
request_handlers.register_lazy(
608
657
    'Repository.insert_stream_1.19', 'bzrlib.smart.repository', 'SmartServerRepositoryInsertStream_1_19')
611
660
request_handlers.register_lazy(
612
661
    'Repository.is_shared', 'bzrlib.smart.repository', 'SmartServerRepositoryIsShared')
613
662
request_handlers.register_lazy(
 
663
    'Repository.iter_files_bytes', 'bzrlib.smart.repository',
 
664
    'SmartServerRepositoryIterFilesBytes')
 
665
request_handlers.register_lazy(
614
666
    'Repository.lock_write', 'bzrlib.smart.repository', 'SmartServerRepositoryLockWrite')
615
667
request_handlers.register_lazy(
 
668
    'Repository.make_working_trees', 'bzrlib.smart.repository', 'SmartServerRepositoryMakeWorkingTrees')
 
669
request_handlers.register_lazy(
616
670
    'Repository.set_make_working_trees', 'bzrlib.smart.repository',
617
671
    'SmartServerRepositorySetMakeWorkingTrees')
618
672
request_handlers.register_lazy(
619
673
    'Repository.unlock', 'bzrlib.smart.repository', 'SmartServerRepositoryUnlock')
620
674
request_handlers.register_lazy(
 
675
    'Repository.get_physical_lock_status', 'bzrlib.smart.repository',
 
676
    'SmartServerRepositoryGetPhysicalLockStatus')
 
677
request_handlers.register_lazy(
621
678
    'Repository.get_rev_id_for_revno', 'bzrlib.smart.repository',
622
679
    'SmartServerRepositoryGetRevIdForRevno')
623
680
request_handlers.register_lazy(
627
684
    'Repository.get_stream_1.19', 'bzrlib.smart.repository',
628
685
    'SmartServerRepositoryGetStream_1_19')
629
686
request_handlers.register_lazy(
 
687
    'Repository.iter_revisions', 'bzrlib.smart.repository',
 
688
    'SmartServerRepositoryIterRevisions')
 
689
request_handlers.register_lazy(
 
690
    'Repository.pack', 'bzrlib.smart.repository',
 
691
    'SmartServerRepositoryPack')
 
692
request_handlers.register_lazy(
630
693
    'Repository.tarball', 'bzrlib.smart.repository',
631
694
    'SmartServerRepositoryTarball')
632
695
request_handlers.register_lazy(
 
696
    'Repository.start_write_group', 'bzrlib.smart.repository',
 
697
    'SmartServerRepositoryStartWriteGroup')
 
698
request_handlers.register_lazy(
 
699
    'Repository.commit_write_group', 'bzrlib.smart.repository',
 
700
    'SmartServerRepositoryCommitWriteGroup')
 
701
request_handlers.register_lazy(
 
702
    'Repository.abort_write_group', 'bzrlib.smart.repository',
 
703
    'SmartServerRepositoryAbortWriteGroup')
 
704
request_handlers.register_lazy(
 
705
    'Repository.check_write_group', 'bzrlib.smart.repository',
 
706
    'SmartServerRepositoryCheckWriteGroup')
 
707
request_handlers.register_lazy(
 
708
    'VersionedFileRepository.get_serializer_format', 'bzrlib.smart.repository',
 
709
    'SmartServerRepositoryGetSerializerFormat')
 
710
request_handlers.register_lazy(
633
711
    'rmdir', 'bzrlib.smart.vfs', 'RmdirRequest')
634
712
request_handlers.register_lazy(
635
713
    'stat', 'bzrlib.smart.vfs', 'StatRequest')