495
495
return SuccessfulSmartServerResponse((answer,))
498
# In the 'info' attribute, we store whether this request is 'safe' to retry if
499
# we get a disconnect while reading the response. It can have the values:
500
# read This is purely a read request, so retrying it is perfectly ok.
501
# idem An idempotent write request. Something like 'put' where if you put
502
# the same bytes twice you end up with the same final bytes.
503
# semi This is a request that isn't strictly idempotent, but doesn't
504
# result in corruption if it is retried. This is for things like
505
# 'lock' and 'unlock'. If you call lock, it updates the disk
506
# structure. If you fail to read the response, you won't be able to
507
# use the lock, because you don't have the lock token. Calling lock
508
# again will fail, because the lock is already taken. However, we
509
# can't tell if the server received our request or not. If it didn't,
510
# then retrying the request is fine, as it will actually do what we
511
# want. If it did, we will interrupt the current operation, but we
512
# are no worse off than interrupting the current operation because of
514
# semivfs Similar to semi, but specific to a Virtual FileSystem request.
515
# stream This is a request that takes a stream that cannot be restarted if
516
# consumed. This request is 'safe' in that if we determine the
517
# connection is closed before we consume the stream, we can try
519
# mutate State is updated in a way that replaying that request results in a
520
# different state. For example 'append' writes more bytes to a given
521
# file. If append succeeds, it moves the file pointer.
498
522
request_handlers = registry.Registry()
499
523
request_handlers.register_lazy(
500
'append', 'bzrlib.smart.vfs', 'AppendRequest')
524
'append', 'bzrlib.smart.vfs', 'AppendRequest', info='mutate')
501
525
request_handlers.register_lazy(
502
526
'Branch.break_lock', 'bzrlib.smart.branch',
503
'SmartServerBranchBreakLock')
527
'SmartServerBranchBreakLock', info='idem')
504
528
request_handlers.register_lazy(
505
529
'Branch.get_config_file', 'bzrlib.smart.branch',
506
'SmartServerBranchGetConfigFile')
530
'SmartServerBranchGetConfigFile', info='read')
531
request_handlers.register_lazy(
532
'Branch.get_parent', 'bzrlib.smart.branch', 'SmartServerBranchGetParent',
507
534
request_handlers.register_lazy(
508
535
'Branch.put_config_file', 'bzrlib.smart.branch',
509
'SmartServerBranchPutConfigFile')
510
request_handlers.register_lazy(
511
'Branch.get_parent', 'bzrlib.smart.branch', 'SmartServerBranchGetParent')
536
'SmartServerBranchPutConfigFile', info='idem')
512
537
request_handlers.register_lazy(
513
538
'Branch.get_tags_bytes', 'bzrlib.smart.branch',
514
'SmartServerBranchGetTagsBytes')
539
'SmartServerBranchGetTagsBytes', info='read')
515
540
request_handlers.register_lazy(
516
541
'Branch.set_tags_bytes', 'bzrlib.smart.branch',
517
'SmartServerBranchSetTagsBytes')
542
'SmartServerBranchSetTagsBytes', info='idem')
518
543
request_handlers.register_lazy(
519
544
'Branch.heads_to_fetch', 'bzrlib.smart.branch',
520
'SmartServerBranchHeadsToFetch')
521
request_handlers.register_lazy(
522
'Branch.get_stacked_on_url', 'bzrlib.smart.branch', 'SmartServerBranchRequestGetStackedOnURL')
523
request_handlers.register_lazy(
524
'Branch.last_revision_info', 'bzrlib.smart.branch', 'SmartServerBranchRequestLastRevisionInfo')
525
request_handlers.register_lazy(
526
'Branch.lock_write', 'bzrlib.smart.branch', 'SmartServerBranchRequestLockWrite')
545
'SmartServerBranchHeadsToFetch', info='read')
546
request_handlers.register_lazy(
547
'Branch.get_stacked_on_url', 'bzrlib.smart.branch',
548
'SmartServerBranchRequestGetStackedOnURL', info='read')
527
549
request_handlers.register_lazy(
528
550
'Branch.get_physical_lock_status', 'bzrlib.smart.branch',
529
'SmartServerBranchRequestGetPhysicalLockStatus')
530
request_handlers.register_lazy( 'Branch.revision_history',
531
'bzrlib.smart.branch', 'SmartServerRequestRevisionHistory')
532
request_handlers.register_lazy( 'Branch.set_config_option',
533
'bzrlib.smart.branch', 'SmartServerBranchRequestSetConfigOption')
534
request_handlers.register_lazy( 'Branch.set_config_option_dict',
535
'bzrlib.smart.branch', 'SmartServerBranchRequestSetConfigOptionDict')
536
request_handlers.register_lazy( 'Branch.set_last_revision',
537
'bzrlib.smart.branch', 'SmartServerBranchRequestSetLastRevision')
551
'SmartServerBranchRequestGetPhysicalLockStatus', info='read')
552
request_handlers.register_lazy(
553
'Branch.last_revision_info', 'bzrlib.smart.branch',
554
'SmartServerBranchRequestLastRevisionInfo', info='read')
555
request_handlers.register_lazy(
556
'Branch.lock_write', 'bzrlib.smart.branch',
557
'SmartServerBranchRequestLockWrite', info='semi')
558
request_handlers.register_lazy(
559
'Branch.revision_history', 'bzrlib.smart.branch',
560
'SmartServerRequestRevisionHistory', info='read')
561
request_handlers.register_lazy(
562
'Branch.set_config_option', 'bzrlib.smart.branch',
563
'SmartServerBranchRequestSetConfigOption', info='idem')
564
request_handlers.register_lazy(
565
'Branch.set_config_option_dict', 'bzrlib.smart.branch',
566
'SmartServerBranchRequestSetConfigOptionDict', info='idem')
567
request_handlers.register_lazy(
568
'Branch.set_last_revision', 'bzrlib.smart.branch',
569
'SmartServerBranchRequestSetLastRevision', info='idem')
538
570
request_handlers.register_lazy(
539
571
'Branch.set_last_revision_info', 'bzrlib.smart.branch',
540
'SmartServerBranchRequestSetLastRevisionInfo')
572
'SmartServerBranchRequestSetLastRevisionInfo', info='idem')
541
573
request_handlers.register_lazy(
542
574
'Branch.set_last_revision_ex', 'bzrlib.smart.branch',
543
'SmartServerBranchRequestSetLastRevisionEx')
575
'SmartServerBranchRequestSetLastRevisionEx', info='idem')
544
576
request_handlers.register_lazy(
545
577
'Branch.set_parent_location', 'bzrlib.smart.branch',
546
'SmartServerBranchRequestSetParentLocation')
547
request_handlers.register_lazy(
548
'Branch.unlock', 'bzrlib.smart.branch', 'SmartServerBranchRequestUnlock')
549
request_handlers.register_lazy(
550
'Branch.revision_id_to_revno', 'bzrlib.smart.branch', 'SmartServerBranchRequestRevisionIdToRevno')
578
'SmartServerBranchRequestSetParentLocation', info='idem')
579
request_handlers.register_lazy(
580
'Branch.unlock', 'bzrlib.smart.branch',
581
'SmartServerBranchRequestUnlock', info='semi')
582
request_handlers.register_lazy(
583
'Branch.revision_id_to_revno', 'bzrlib.smart.branch',
584
'SmartServerBranchRequestRevisionIdToRevno', info='read')
551
585
request_handlers.register_lazy(
552
586
'BzrDir.cloning_metadir', 'bzrlib.smart.bzrdir',
553
'SmartServerBzrDirRequestCloningMetaDir')
587
'SmartServerBzrDirRequestCloningMetaDir', info='read')
554
588
request_handlers.register_lazy(
555
589
'BzrDir.create_branch', 'bzrlib.smart.bzrdir',
556
'SmartServerRequestCreateBranch')
590
'SmartServerRequestCreateBranch', info='semi')
557
591
request_handlers.register_lazy(
558
592
'BzrDir.create_repository', 'bzrlib.smart.bzrdir',
559
'SmartServerRequestCreateRepository')
593
'SmartServerRequestCreateRepository', info='semi')
560
594
request_handlers.register_lazy(
561
595
'BzrDir.find_repository', 'bzrlib.smart.bzrdir',
562
'SmartServerRequestFindRepositoryV1')
596
'SmartServerRequestFindRepositoryV1', info='read')
563
597
request_handlers.register_lazy(
564
598
'BzrDir.find_repositoryV2', 'bzrlib.smart.bzrdir',
565
'SmartServerRequestFindRepositoryV2')
599
'SmartServerRequestFindRepositoryV2', info='read')
566
600
request_handlers.register_lazy(
567
601
'BzrDir.find_repositoryV3', 'bzrlib.smart.bzrdir',
568
'SmartServerRequestFindRepositoryV3')
602
'SmartServerRequestFindRepositoryV3', info='read')
569
603
request_handlers.register_lazy(
570
604
'BzrDir.get_config_file', 'bzrlib.smart.bzrdir',
571
'SmartServerBzrDirRequestConfigFile')
605
'SmartServerBzrDirRequestConfigFile', info='read')
572
606
request_handlers.register_lazy(
573
607
'BzrDir.destroy_branch', 'bzrlib.smart.bzrdir',
574
'SmartServerBzrDirRequestDestroyBranch')
608
'SmartServerBzrDirRequestDestroyBranch', info='semi')
575
609
request_handlers.register_lazy(
576
610
'BzrDir.destroy_repository', 'bzrlib.smart.bzrdir',
577
'SmartServerBzrDirRequestDestroyRepository')
611
'SmartServerBzrDirRequestDestroyRepository', info='semi')
578
612
request_handlers.register_lazy(
579
613
'BzrDir.has_workingtree', 'bzrlib.smart.bzrdir',
580
'SmartServerBzrDirRequestHasWorkingTree')
614
'SmartServerBzrDirRequestHasWorkingTree', info='read')
581
615
request_handlers.register_lazy(
582
616
'BzrDirFormat.initialize', 'bzrlib.smart.bzrdir',
583
'SmartServerRequestInitializeBzrDir')
617
'SmartServerRequestInitializeBzrDir', info='semi')
584
618
request_handlers.register_lazy(
585
619
'BzrDirFormat.initialize_ex_1.16', 'bzrlib.smart.bzrdir',
586
'SmartServerRequestBzrDirInitializeEx')
587
request_handlers.register_lazy(
588
'BzrDir.open', 'bzrlib.smart.bzrdir', 'SmartServerRequestOpenBzrDir')
589
request_handlers.register_lazy(
590
'BzrDir.open_2.1', 'bzrlib.smart.bzrdir', 'SmartServerRequestOpenBzrDir_2_1')
620
'SmartServerRequestBzrDirInitializeEx', info='semi')
621
request_handlers.register_lazy(
622
'BzrDir.open', 'bzrlib.smart.bzrdir', 'SmartServerRequestOpenBzrDir',
624
request_handlers.register_lazy(
625
'BzrDir.open_2.1', 'bzrlib.smart.bzrdir',
626
'SmartServerRequestOpenBzrDir_2_1', info='read')
591
627
request_handlers.register_lazy(
592
628
'BzrDir.open_branch', 'bzrlib.smart.bzrdir',
593
'SmartServerRequestOpenBranch')
629
'SmartServerRequestOpenBranch', info='read')
594
630
request_handlers.register_lazy(
595
631
'BzrDir.open_branchV2', 'bzrlib.smart.bzrdir',
596
'SmartServerRequestOpenBranchV2')
632
'SmartServerRequestOpenBranchV2', info='read')
597
633
request_handlers.register_lazy(
598
634
'BzrDir.open_branchV3', 'bzrlib.smart.bzrdir',
599
'SmartServerRequestOpenBranchV3')
600
request_handlers.register_lazy(
601
'delete', 'bzrlib.smart.vfs', 'DeleteRequest')
602
request_handlers.register_lazy(
603
'get', 'bzrlib.smart.vfs', 'GetRequest')
604
request_handlers.register_lazy(
605
'get_bundle', 'bzrlib.smart.request', 'GetBundleRequest')
606
request_handlers.register_lazy(
607
'has', 'bzrlib.smart.vfs', 'HasRequest')
608
request_handlers.register_lazy(
609
'hello', 'bzrlib.smart.request', 'HelloRequest')
610
request_handlers.register_lazy(
611
'iter_files_recursive', 'bzrlib.smart.vfs', 'IterFilesRecursiveRequest')
612
request_handlers.register_lazy(
613
'list_dir', 'bzrlib.smart.vfs', 'ListDirRequest')
614
request_handlers.register_lazy(
615
'mkdir', 'bzrlib.smart.vfs', 'MkdirRequest')
616
request_handlers.register_lazy(
617
'move', 'bzrlib.smart.vfs', 'MoveRequest')
618
request_handlers.register_lazy(
619
'put', 'bzrlib.smart.vfs', 'PutRequest')
620
request_handlers.register_lazy(
621
'put_non_atomic', 'bzrlib.smart.vfs', 'PutNonAtomicRequest')
622
request_handlers.register_lazy(
623
'readv', 'bzrlib.smart.vfs', 'ReadvRequest')
624
request_handlers.register_lazy(
625
'rename', 'bzrlib.smart.vfs', 'RenameRequest')
635
'SmartServerRequestOpenBranchV3', info='read')
636
request_handlers.register_lazy(
637
'delete', 'bzrlib.smart.vfs', 'DeleteRequest', info='semivfs')
638
request_handlers.register_lazy(
639
'get', 'bzrlib.smart.vfs', 'GetRequest', info='read')
640
request_handlers.register_lazy(
641
'get_bundle', 'bzrlib.smart.request', 'GetBundleRequest', info='read')
642
request_handlers.register_lazy(
643
'has', 'bzrlib.smart.vfs', 'HasRequest', info='read')
644
request_handlers.register_lazy(
645
'hello', 'bzrlib.smart.request', 'HelloRequest', info='read')
646
request_handlers.register_lazy(
647
'iter_files_recursive', 'bzrlib.smart.vfs', 'IterFilesRecursiveRequest',
649
request_handlers.register_lazy(
650
'list_dir', 'bzrlib.smart.vfs', 'ListDirRequest', info='read')
651
request_handlers.register_lazy(
652
'mkdir', 'bzrlib.smart.vfs', 'MkdirRequest', info='semivfs')
653
request_handlers.register_lazy(
654
'move', 'bzrlib.smart.vfs', 'MoveRequest', info='semivfs')
655
request_handlers.register_lazy(
656
'put', 'bzrlib.smart.vfs', 'PutRequest', info='idem')
657
request_handlers.register_lazy(
658
'put_non_atomic', 'bzrlib.smart.vfs', 'PutNonAtomicRequest', info='idem')
659
request_handlers.register_lazy(
660
'readv', 'bzrlib.smart.vfs', 'ReadvRequest', info='read')
661
request_handlers.register_lazy(
662
'rename', 'bzrlib.smart.vfs', 'RenameRequest', info='semivfs')
663
request_handlers.register_lazy(
664
'Repository.add_signature_text', 'bzrlib.smart.repository',
665
'SmartServerRepositoryAddSignatureText', info='idem')
666
request_handlers.register_lazy(
667
'Repository.all_revision_ids', 'bzrlib.smart.repository',
668
'SmartServerRepositoryAllRevisionIds', info='read')
626
669
request_handlers.register_lazy(
627
670
'PackRepository.autopack', 'bzrlib.smart.packrepository',
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')
635
request_handlers.register_lazy('Repository.gather_stats',
636
'bzrlib.smart.repository',
637
'SmartServerRepositoryGatherStats')
638
request_handlers.register_lazy('Repository.get_parent_map',
639
'bzrlib.smart.repository',
640
'SmartServerRepositoryGetParentMap')
641
request_handlers.register_lazy(
642
'Repository.add_signature_text', 'bzrlib.smart.repository',
643
'SmartServerRepositoryAddSignatureText')
644
request_handlers.register_lazy(
645
'Repository.get_revision_graph', 'bzrlib.smart.repository', 'SmartServerRepositoryGetRevisionGraph')
671
'SmartServerPackRepositoryAutopack', info='idem')
672
request_handlers.register_lazy(
673
'Repository.break_lock', 'bzrlib.smart.repository',
674
'SmartServerRepositoryBreakLock', info='idem')
675
request_handlers.register_lazy(
676
'Repository.gather_stats', 'bzrlib.smart.repository',
677
'SmartServerRepositoryGatherStats', info='read')
678
request_handlers.register_lazy(
679
'Repository.get_parent_map', 'bzrlib.smart.repository',
680
'SmartServerRepositoryGetParentMap', info='read')
681
request_handlers.register_lazy(
682
'Repository.get_revision_graph', 'bzrlib.smart.repository',
683
'SmartServerRepositoryGetRevisionGraph', info='read')
646
684
request_handlers.register_lazy(
647
685
'Repository.get_revision_signature_text', 'bzrlib.smart.repository',
648
'SmartServerRepositoryGetRevisionSignatureText')
686
'SmartServerRepositoryGetRevisionSignatureText', info='read')
649
687
request_handlers.register_lazy(
650
'Repository.has_revision', 'bzrlib.smart.repository', 'SmartServerRequestHasRevision')
688
'Repository.has_revision', 'bzrlib.smart.repository',
689
'SmartServerRequestHasRevision', info='read')
651
690
request_handlers.register_lazy(
652
691
'Repository.has_signature_for_revision_id', 'bzrlib.smart.repository',
653
'SmartServerRequestHasSignatureForRevisionId')
654
request_handlers.register_lazy(
655
'Repository.insert_stream', 'bzrlib.smart.repository', 'SmartServerRepositoryInsertStream')
656
request_handlers.register_lazy(
657
'Repository.insert_stream_1.19', 'bzrlib.smart.repository', 'SmartServerRepositoryInsertStream_1_19')
658
request_handlers.register_lazy(
659
'Repository.insert_stream_locked', 'bzrlib.smart.repository', 'SmartServerRepositoryInsertStreamLocked')
660
request_handlers.register_lazy(
661
'Repository.is_shared', 'bzrlib.smart.repository', 'SmartServerRepositoryIsShared')
692
'SmartServerRequestHasSignatureForRevisionId', info='read')
693
request_handlers.register_lazy(
694
'Repository.insert_stream', 'bzrlib.smart.repository',
695
'SmartServerRepositoryInsertStream', info='stream')
696
request_handlers.register_lazy(
697
'Repository.insert_stream_1.19', 'bzrlib.smart.repository',
698
'SmartServerRepositoryInsertStream_1_19', info='stream')
699
request_handlers.register_lazy(
700
'Repository.insert_stream_locked', 'bzrlib.smart.repository',
701
'SmartServerRepositoryInsertStreamLocked', info='stream')
702
request_handlers.register_lazy(
703
'Repository.is_shared', 'bzrlib.smart.repository',
704
'SmartServerRepositoryIsShared', info='read')
662
705
request_handlers.register_lazy(
663
706
'Repository.iter_files_bytes', 'bzrlib.smart.repository',
664
'SmartServerRepositoryIterFilesBytes')
665
request_handlers.register_lazy(
666
'Repository.lock_write', 'bzrlib.smart.repository', 'SmartServerRepositoryLockWrite')
667
request_handlers.register_lazy(
668
'Repository.make_working_trees', 'bzrlib.smart.repository', 'SmartServerRepositoryMakeWorkingTrees')
707
'SmartServerRepositoryIterFilesBytes', info='read')
708
request_handlers.register_lazy(
709
'Repository.lock_write', 'bzrlib.smart.repository',
710
'SmartServerRepositoryLockWrite', info='semi')
711
request_handlers.register_lazy(
712
'Repository.make_working_trees', 'bzrlib.smart.repository',
713
'SmartServerRepositoryMakeWorkingTrees', info='read')
669
714
request_handlers.register_lazy(
670
715
'Repository.set_make_working_trees', 'bzrlib.smart.repository',
671
'SmartServerRepositorySetMakeWorkingTrees')
716
'SmartServerRepositorySetMakeWorkingTrees', info='idem')
672
717
request_handlers.register_lazy(
673
'Repository.unlock', 'bzrlib.smart.repository', 'SmartServerRepositoryUnlock')
718
'Repository.unlock', 'bzrlib.smart.repository',
719
'SmartServerRepositoryUnlock', info='semi')
674
720
request_handlers.register_lazy(
675
721
'Repository.get_physical_lock_status', 'bzrlib.smart.repository',
676
'SmartServerRepositoryGetPhysicalLockStatus')
722
'SmartServerRepositoryGetPhysicalLockStatus', info='read')
677
723
request_handlers.register_lazy(
678
724
'Repository.get_rev_id_for_revno', 'bzrlib.smart.repository',
679
'SmartServerRepositoryGetRevIdForRevno')
725
'SmartServerRepositoryGetRevIdForRevno', info='read')
680
726
request_handlers.register_lazy(
681
727
'Repository.get_stream', 'bzrlib.smart.repository',
682
'SmartServerRepositoryGetStream')
728
'SmartServerRepositoryGetStream', info='read')
683
729
request_handlers.register_lazy(
684
730
'Repository.get_stream_1.19', 'bzrlib.smart.repository',
685
'SmartServerRepositoryGetStream_1_19')
731
'SmartServerRepositoryGetStream_1_19', info='read')
686
732
request_handlers.register_lazy(
687
733
'Repository.iter_revisions', 'bzrlib.smart.repository',
688
'SmartServerRepositoryIterRevisions')
734
'SmartServerRepositoryIterRevisions', info='read')
689
735
request_handlers.register_lazy(
690
736
'Repository.pack', 'bzrlib.smart.repository',
691
'SmartServerRepositoryPack')
692
request_handlers.register_lazy(
693
'Repository.tarball', 'bzrlib.smart.repository',
694
'SmartServerRepositoryTarball')
737
'SmartServerRepositoryPack', info='idem')
695
738
request_handlers.register_lazy(
696
739
'Repository.start_write_group', 'bzrlib.smart.repository',
697
'SmartServerRepositoryStartWriteGroup')
740
'SmartServerRepositoryStartWriteGroup', info='semi')
698
741
request_handlers.register_lazy(
699
742
'Repository.commit_write_group', 'bzrlib.smart.repository',
700
'SmartServerRepositoryCommitWriteGroup')
743
'SmartServerRepositoryCommitWriteGroup', info='semi')
701
744
request_handlers.register_lazy(
702
745
'Repository.abort_write_group', 'bzrlib.smart.repository',
703
'SmartServerRepositoryAbortWriteGroup')
746
'SmartServerRepositoryAbortWriteGroup', info='semi')
704
747
request_handlers.register_lazy(
705
748
'Repository.check_write_group', 'bzrlib.smart.repository',
706
'SmartServerRepositoryCheckWriteGroup')
749
'SmartServerRepositoryCheckWriteGroup', info='read')
707
750
request_handlers.register_lazy(
708
751
'VersionedFileRepository.get_serializer_format', 'bzrlib.smart.repository',
709
'SmartServerRepositoryGetSerializerFormat')
710
request_handlers.register_lazy(
711
'rmdir', 'bzrlib.smart.vfs', 'RmdirRequest')
712
request_handlers.register_lazy(
713
'stat', 'bzrlib.smart.vfs', 'StatRequest')
714
request_handlers.register_lazy(
715
'Transport.is_readonly', 'bzrlib.smart.request', 'SmartServerIsReadonly')
752
'SmartServerRepositoryGetSerializerFormat', info='read')
753
request_handlers.register_lazy(
754
'Repository.tarball', 'bzrlib.smart.repository',
755
'SmartServerRepositoryTarball', info='read')
756
request_handlers.register_lazy(
757
'rmdir', 'bzrlib.smart.vfs', 'RmdirRequest', info='semivfs')
758
request_handlers.register_lazy(
759
'stat', 'bzrlib.smart.vfs', 'StatRequest', info='read')
760
request_handlers.register_lazy(
761
'Transport.is_readonly', 'bzrlib.smart.request',
762
'SmartServerIsReadonly', info='read')