/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: Jelmer Vernooij
  • Date: 2011-11-27 16:55:11 UTC
  • mto: This revision was merged to the branch mainline in revision 6311.
  • Revision ID: jelmer@samba.org-20111127165511-2h20hkri53u4sbok
Only make a single connection.

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)
420
421
        return ('UnstackableBranchFormat', str(err.format), err.url)
421
422
    elif isinstance(err, errors.NotStacked):
422
423
        return ('NotStacked',)
 
424
    elif isinstance(err, errors.BzrCheckError):
 
425
        return ('BzrCheckError', err.msg)
423
426
    elif isinstance(err, UnicodeError):
424
427
        # If it is a DecodeError, than most likely we are starting
425
428
        # with a plain string
446
449
        return ('TokenMismatch', err.given_token, err.lock_token)
447
450
    elif isinstance(err, errors.LockContention):
448
451
        return ('LockContention',)
 
452
    elif isinstance(err, MemoryError):
 
453
        # GZ 2011-02-24: Copy bzrlib.trace -Dmem_dump functionality here?
 
454
        return ('MemoryError',)
449
455
    # Unserialisable error.  Log it, and return a generic error
450
456
    trace.log_exception_quietly()
451
 
    return ('error', str(err))
 
457
    return ('error', trace._qualified_exception_name(err.__class__, True),
 
458
        str(err))
452
459
 
453
460
 
454
461
class HelloRequest(SmartServerRequest):
490
497
request_handlers.register_lazy(
491
498
    'append', 'bzrlib.smart.vfs', 'AppendRequest')
492
499
request_handlers.register_lazy(
 
500
    'Branch.break_lock', 'bzrlib.smart.branch',
 
501
    'SmartServerBranchBreakLock')
 
502
request_handlers.register_lazy(
493
503
    'Branch.get_config_file', 'bzrlib.smart.branch',
494
504
    'SmartServerBranchGetConfigFile')
495
505
request_handlers.register_lazy(
 
506
    'Branch.put_config_file', 'bzrlib.smart.branch',
 
507
    'SmartServerBranchPutConfigFile')
 
508
request_handlers.register_lazy(
496
509
    'Branch.get_parent', 'bzrlib.smart.branch', 'SmartServerBranchGetParent')
497
510
request_handlers.register_lazy(
498
511
    'Branch.get_tags_bytes', 'bzrlib.smart.branch',
501
514
    'Branch.set_tags_bytes', 'bzrlib.smart.branch',
502
515
    'SmartServerBranchSetTagsBytes')
503
516
request_handlers.register_lazy(
 
517
    'Branch.heads_to_fetch', 'bzrlib.smart.branch',
 
518
    'SmartServerBranchHeadsToFetch')
 
519
request_handlers.register_lazy(
504
520
    'Branch.get_stacked_on_url', 'bzrlib.smart.branch', 'SmartServerBranchRequestGetStackedOnURL')
505
521
request_handlers.register_lazy(
506
522
    'Branch.last_revision_info', 'bzrlib.smart.branch', 'SmartServerBranchRequestLastRevisionInfo')
507
523
request_handlers.register_lazy(
508
524
    'Branch.lock_write', 'bzrlib.smart.branch', 'SmartServerBranchRequestLockWrite')
 
525
request_handlers.register_lazy(
 
526
    'Branch.get_physical_lock_status', 'bzrlib.smart.branch',
 
527
    'SmartServerBranchRequestGetPhysicalLockStatus')
509
528
request_handlers.register_lazy( 'Branch.revision_history',
510
529
    'bzrlib.smart.branch', 'SmartServerRequestRevisionHistory')
511
530
request_handlers.register_lazy( 'Branch.set_config_option',
512
531
    'bzrlib.smart.branch', 'SmartServerBranchRequestSetConfigOption')
 
532
request_handlers.register_lazy( 'Branch.set_config_option_dict',
 
533
    'bzrlib.smart.branch', 'SmartServerBranchRequestSetConfigOptionDict')
513
534
request_handlers.register_lazy( 'Branch.set_last_revision',
514
535
    'bzrlib.smart.branch', 'SmartServerBranchRequestSetLastRevision')
515
536
request_handlers.register_lazy(
524
545
request_handlers.register_lazy(
525
546
    'Branch.unlock', 'bzrlib.smart.branch', 'SmartServerBranchRequestUnlock')
526
547
request_handlers.register_lazy(
 
548
    'Branch.revision_id_to_revno', 'bzrlib.smart.branch', 'SmartServerBranchRequestRevisionIdToRevno')
 
549
request_handlers.register_lazy(
527
550
    'BzrDir.cloning_metadir', 'bzrlib.smart.bzrdir',
528
551
    'SmartServerBzrDirRequestCloningMetaDir')
529
552
request_handlers.register_lazy(
545
568
    'BzrDir.get_config_file', 'bzrlib.smart.bzrdir',
546
569
    'SmartServerBzrDirRequestConfigFile')
547
570
request_handlers.register_lazy(
 
571
    'BzrDir.destroy_branch', 'bzrlib.smart.bzrdir',
 
572
    'SmartServerBzrDirRequestDestroyBranch')
 
573
request_handlers.register_lazy(
 
574
    'BzrDir.destroy_repository', 'bzrlib.smart.bzrdir',
 
575
    'SmartServerBzrDirRequestDestroyRepository')
 
576
request_handlers.register_lazy(
 
577
    'BzrDir.has_workingtree', 'bzrlib.smart.bzrdir',
 
578
    'SmartServerBzrDirRequestHasWorkingTree')
 
579
request_handlers.register_lazy(
548
580
    'BzrDirFormat.initialize', 'bzrlib.smart.bzrdir',
549
581
    'SmartServerRequestInitializeBzrDir')
550
582
request_handlers.register_lazy(
592
624
request_handlers.register_lazy(
593
625
    'PackRepository.autopack', 'bzrlib.smart.packrepository',
594
626
    'SmartServerPackRepositoryAutopack')
 
627
request_handlers.register_lazy('Repository.all_revision_ids',
 
628
                               'bzrlib.smart.repository',
 
629
                               'SmartServerRepositoryAllRevisionIds')
 
630
request_handlers.register_lazy('Repository.break_lock',
 
631
                               'bzrlib.smart.repository',
 
632
                               'SmartServerRepositoryBreakLock')
595
633
request_handlers.register_lazy('Repository.gather_stats',
596
634
                               'bzrlib.smart.repository',
597
635
                               'SmartServerRepositoryGatherStats')
603
641
request_handlers.register_lazy(
604
642
    'Repository.has_revision', 'bzrlib.smart.repository', 'SmartServerRequestHasRevision')
605
643
request_handlers.register_lazy(
 
644
    'Repository.has_signature_for_revision_id', 'bzrlib.smart.repository',
 
645
    'SmartServerRequestHasSignatureForRevisionId')
 
646
request_handlers.register_lazy(
606
647
    'Repository.insert_stream', 'bzrlib.smart.repository', 'SmartServerRepositoryInsertStream')
607
648
request_handlers.register_lazy(
608
649
    'Repository.insert_stream_1.19', 'bzrlib.smart.repository', 'SmartServerRepositoryInsertStream_1_19')
613
654
request_handlers.register_lazy(
614
655
    'Repository.lock_write', 'bzrlib.smart.repository', 'SmartServerRepositoryLockWrite')
615
656
request_handlers.register_lazy(
 
657
    'Repository.make_working_trees', 'bzrlib.smart.repository', 'SmartServerRepositoryMakeWorkingTrees')
 
658
request_handlers.register_lazy(
616
659
    'Repository.set_make_working_trees', 'bzrlib.smart.repository',
617
660
    'SmartServerRepositorySetMakeWorkingTrees')
618
661
request_handlers.register_lazy(
619
662
    'Repository.unlock', 'bzrlib.smart.repository', 'SmartServerRepositoryUnlock')
620
663
request_handlers.register_lazy(
 
664
    'Repository.get_physical_lock_status', 'bzrlib.smart.repository',
 
665
    'SmartServerRepositoryGetPhysicalLockStatus')
 
666
request_handlers.register_lazy(
621
667
    'Repository.get_rev_id_for_revno', 'bzrlib.smart.repository',
622
668
    'SmartServerRepositoryGetRevIdForRevno')
623
669
request_handlers.register_lazy(
630
676
    'Repository.tarball', 'bzrlib.smart.repository',
631
677
    'SmartServerRepositoryTarball')
632
678
request_handlers.register_lazy(
 
679
    'Repository.start_write_group', 'bzrlib.smart.repository',
 
680
    'SmartServerRepositoryStartWriteGroup')
 
681
request_handlers.register_lazy(
 
682
    'Repository.commit_write_group', 'bzrlib.smart.repository',
 
683
    'SmartServerRepositoryCommitWriteGroup')
 
684
request_handlers.register_lazy(
 
685
    'Repository.abort_write_group', 'bzrlib.smart.repository',
 
686
    'SmartServerRepositoryAbortWriteGroup')
 
687
request_handlers.register_lazy(
 
688
    'Repository.check_write_group', 'bzrlib.smart.repository',
 
689
    'SmartServerRepositoryCheckWriteGroup')
 
690
request_handlers.register_lazy(
 
691
    'VersionedFileRepository.get_serializer_format', 'bzrlib.smart.repository',
 
692
    'SmartServerRepositoryGetSerializerFormat')
 
693
request_handlers.register_lazy(
633
694
    'rmdir', 'bzrlib.smart.vfs', 'RmdirRequest')
634
695
request_handlers.register_lazy(
635
696
    'stat', 'bzrlib.smart.vfs', 'StatRequest')