/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: Robert Collins
  • Date: 2010-05-06 11:08:10 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506110810-h3j07fh5gmw54s25
Cleaner matcher matching revised unlocking protocol.

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