486
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.
489
522
request_handlers = registry.Registry()
490
523
request_handlers.register_lazy(
491
'append', 'bzrlib.smart.vfs', 'AppendRequest')
524
'append', 'bzrlib.smart.vfs', 'AppendRequest', info='mutate')
525
request_handlers.register_lazy(
526
'Branch.break_lock', 'bzrlib.smart.branch',
527
'SmartServerBranchBreakLock', info='idem')
492
528
request_handlers.register_lazy(
493
529
'Branch.get_config_file', 'bzrlib.smart.branch',
494
'SmartServerBranchGetConfigFile')
495
request_handlers.register_lazy(
496
'Branch.get_parent', 'bzrlib.smart.branch', 'SmartServerBranchGetParent')
530
'SmartServerBranchGetConfigFile', info='read')
531
request_handlers.register_lazy(
532
'Branch.get_parent', 'bzrlib.smart.branch', 'SmartServerBranchGetParent',
534
request_handlers.register_lazy(
535
'Branch.put_config_file', 'bzrlib.smart.branch',
536
'SmartServerBranchPutConfigFile', info='idem')
497
537
request_handlers.register_lazy(
498
538
'Branch.get_tags_bytes', 'bzrlib.smart.branch',
499
'SmartServerBranchGetTagsBytes')
539
'SmartServerBranchGetTagsBytes', info='read')
500
540
request_handlers.register_lazy(
501
541
'Branch.set_tags_bytes', 'bzrlib.smart.branch',
502
'SmartServerBranchSetTagsBytes')
503
request_handlers.register_lazy(
504
'Branch.get_stacked_on_url', 'bzrlib.smart.branch', 'SmartServerBranchRequestGetStackedOnURL')
505
request_handlers.register_lazy(
506
'Branch.last_revision_info', 'bzrlib.smart.branch', 'SmartServerBranchRequestLastRevisionInfo')
507
request_handlers.register_lazy(
508
'Branch.lock_write', 'bzrlib.smart.branch', 'SmartServerBranchRequestLockWrite')
509
request_handlers.register_lazy( 'Branch.revision_history',
510
'bzrlib.smart.branch', 'SmartServerRequestRevisionHistory')
511
request_handlers.register_lazy( 'Branch.set_config_option',
512
'bzrlib.smart.branch', 'SmartServerBranchRequestSetConfigOption')
513
request_handlers.register_lazy( 'Branch.set_config_option_dict',
514
'bzrlib.smart.branch', 'SmartServerBranchRequestSetConfigOptionDict')
515
request_handlers.register_lazy( 'Branch.set_last_revision',
516
'bzrlib.smart.branch', 'SmartServerBranchRequestSetLastRevision')
542
'SmartServerBranchSetTagsBytes', info='idem')
543
request_handlers.register_lazy(
544
'Branch.heads_to_fetch', 'bzrlib.smart.branch',
545
'SmartServerBranchHeadsToFetch', info='read')
546
request_handlers.register_lazy(
547
'Branch.get_stacked_on_url', 'bzrlib.smart.branch',
548
'SmartServerBranchRequestGetStackedOnURL', info='read')
549
request_handlers.register_lazy(
550
'Branch.get_physical_lock_status', 'bzrlib.smart.branch',
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')
517
570
request_handlers.register_lazy(
518
571
'Branch.set_last_revision_info', 'bzrlib.smart.branch',
519
'SmartServerBranchRequestSetLastRevisionInfo')
572
'SmartServerBranchRequestSetLastRevisionInfo', info='idem')
520
573
request_handlers.register_lazy(
521
574
'Branch.set_last_revision_ex', 'bzrlib.smart.branch',
522
'SmartServerBranchRequestSetLastRevisionEx')
575
'SmartServerBranchRequestSetLastRevisionEx', info='idem')
523
576
request_handlers.register_lazy(
524
577
'Branch.set_parent_location', 'bzrlib.smart.branch',
525
'SmartServerBranchRequestSetParentLocation')
526
request_handlers.register_lazy(
527
'Branch.unlock', 'bzrlib.smart.branch', 'SmartServerBranchRequestUnlock')
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')
585
request_handlers.register_lazy(
586
'BzrDir.checkout_metadir', 'bzrlib.smart.bzrdir',
587
'SmartServerBzrDirRequestCheckoutMetaDir', info='read')
528
588
request_handlers.register_lazy(
529
589
'BzrDir.cloning_metadir', 'bzrlib.smart.bzrdir',
530
'SmartServerBzrDirRequestCloningMetaDir')
590
'SmartServerBzrDirRequestCloningMetaDir', info='read')
531
591
request_handlers.register_lazy(
532
592
'BzrDir.create_branch', 'bzrlib.smart.bzrdir',
533
'SmartServerRequestCreateBranch')
593
'SmartServerRequestCreateBranch', info='semi')
534
594
request_handlers.register_lazy(
535
595
'BzrDir.create_repository', 'bzrlib.smart.bzrdir',
536
'SmartServerRequestCreateRepository')
596
'SmartServerRequestCreateRepository', info='semi')
537
597
request_handlers.register_lazy(
538
598
'BzrDir.find_repository', 'bzrlib.smart.bzrdir',
539
'SmartServerRequestFindRepositoryV1')
599
'SmartServerRequestFindRepositoryV1', info='read')
540
600
request_handlers.register_lazy(
541
601
'BzrDir.find_repositoryV2', 'bzrlib.smart.bzrdir',
542
'SmartServerRequestFindRepositoryV2')
602
'SmartServerRequestFindRepositoryV2', info='read')
543
603
request_handlers.register_lazy(
544
604
'BzrDir.find_repositoryV3', 'bzrlib.smart.bzrdir',
545
'SmartServerRequestFindRepositoryV3')
605
'SmartServerRequestFindRepositoryV3', info='read')
546
606
request_handlers.register_lazy(
547
607
'BzrDir.get_config_file', 'bzrlib.smart.bzrdir',
548
'SmartServerBzrDirRequestConfigFile')
608
'SmartServerBzrDirRequestConfigFile', info='read')
609
request_handlers.register_lazy(
610
'BzrDir.destroy_branch', 'bzrlib.smart.bzrdir',
611
'SmartServerBzrDirRequestDestroyBranch', info='semi')
612
request_handlers.register_lazy(
613
'BzrDir.destroy_repository', 'bzrlib.smart.bzrdir',
614
'SmartServerBzrDirRequestDestroyRepository', info='semi')
615
request_handlers.register_lazy(
616
'BzrDir.has_workingtree', 'bzrlib.smart.bzrdir',
617
'SmartServerBzrDirRequestHasWorkingTree', info='read')
549
618
request_handlers.register_lazy(
550
619
'BzrDirFormat.initialize', 'bzrlib.smart.bzrdir',
551
'SmartServerRequestInitializeBzrDir')
620
'SmartServerRequestInitializeBzrDir', info='semi')
552
621
request_handlers.register_lazy(
553
622
'BzrDirFormat.initialize_ex_1.16', 'bzrlib.smart.bzrdir',
554
'SmartServerRequestBzrDirInitializeEx')
555
request_handlers.register_lazy(
556
'BzrDir.open', 'bzrlib.smart.bzrdir', 'SmartServerRequestOpenBzrDir')
557
request_handlers.register_lazy(
558
'BzrDir.open_2.1', 'bzrlib.smart.bzrdir', 'SmartServerRequestOpenBzrDir_2_1')
623
'SmartServerRequestBzrDirInitializeEx', info='semi')
624
request_handlers.register_lazy(
625
'BzrDir.open', 'bzrlib.smart.bzrdir', 'SmartServerRequestOpenBzrDir',
627
request_handlers.register_lazy(
628
'BzrDir.open_2.1', 'bzrlib.smart.bzrdir',
629
'SmartServerRequestOpenBzrDir_2_1', info='read')
559
630
request_handlers.register_lazy(
560
631
'BzrDir.open_branch', 'bzrlib.smart.bzrdir',
561
'SmartServerRequestOpenBranch')
632
'SmartServerRequestOpenBranch', info='read')
562
633
request_handlers.register_lazy(
563
634
'BzrDir.open_branchV2', 'bzrlib.smart.bzrdir',
564
'SmartServerRequestOpenBranchV2')
635
'SmartServerRequestOpenBranchV2', info='read')
565
636
request_handlers.register_lazy(
566
637
'BzrDir.open_branchV3', 'bzrlib.smart.bzrdir',
567
'SmartServerRequestOpenBranchV3')
568
request_handlers.register_lazy(
569
'delete', 'bzrlib.smart.vfs', 'DeleteRequest')
570
request_handlers.register_lazy(
571
'get', 'bzrlib.smart.vfs', 'GetRequest')
572
request_handlers.register_lazy(
573
'get_bundle', 'bzrlib.smart.request', 'GetBundleRequest')
574
request_handlers.register_lazy(
575
'has', 'bzrlib.smart.vfs', 'HasRequest')
576
request_handlers.register_lazy(
577
'hello', 'bzrlib.smart.request', 'HelloRequest')
578
request_handlers.register_lazy(
579
'iter_files_recursive', 'bzrlib.smart.vfs', 'IterFilesRecursiveRequest')
580
request_handlers.register_lazy(
581
'list_dir', 'bzrlib.smart.vfs', 'ListDirRequest')
582
request_handlers.register_lazy(
583
'mkdir', 'bzrlib.smart.vfs', 'MkdirRequest')
584
request_handlers.register_lazy(
585
'move', 'bzrlib.smart.vfs', 'MoveRequest')
586
request_handlers.register_lazy(
587
'put', 'bzrlib.smart.vfs', 'PutRequest')
588
request_handlers.register_lazy(
589
'put_non_atomic', 'bzrlib.smart.vfs', 'PutNonAtomicRequest')
590
request_handlers.register_lazy(
591
'readv', 'bzrlib.smart.vfs', 'ReadvRequest')
592
request_handlers.register_lazy(
593
'rename', 'bzrlib.smart.vfs', 'RenameRequest')
638
'SmartServerRequestOpenBranchV3', info='read')
639
request_handlers.register_lazy(
640
'delete', 'bzrlib.smart.vfs', 'DeleteRequest', info='semivfs')
641
request_handlers.register_lazy(
642
'get', 'bzrlib.smart.vfs', 'GetRequest', info='read')
643
request_handlers.register_lazy(
644
'get_bundle', 'bzrlib.smart.request', 'GetBundleRequest', info='read')
645
request_handlers.register_lazy(
646
'has', 'bzrlib.smart.vfs', 'HasRequest', info='read')
647
request_handlers.register_lazy(
648
'hello', 'bzrlib.smart.request', 'HelloRequest', info='read')
649
request_handlers.register_lazy(
650
'iter_files_recursive', 'bzrlib.smart.vfs', 'IterFilesRecursiveRequest',
652
request_handlers.register_lazy(
653
'list_dir', 'bzrlib.smart.vfs', 'ListDirRequest', info='read')
654
request_handlers.register_lazy(
655
'mkdir', 'bzrlib.smart.vfs', 'MkdirRequest', info='semivfs')
656
request_handlers.register_lazy(
657
'move', 'bzrlib.smart.vfs', 'MoveRequest', info='semivfs')
658
request_handlers.register_lazy(
659
'put', 'bzrlib.smart.vfs', 'PutRequest', info='idem')
660
request_handlers.register_lazy(
661
'put_non_atomic', 'bzrlib.smart.vfs', 'PutNonAtomicRequest', info='idem')
662
request_handlers.register_lazy(
663
'readv', 'bzrlib.smart.vfs', 'ReadvRequest', info='read')
664
request_handlers.register_lazy(
665
'rename', 'bzrlib.smart.vfs', 'RenameRequest', info='semivfs')
666
request_handlers.register_lazy(
667
'Repository.add_signature_text', 'bzrlib.smart.repository',
668
'SmartServerRepositoryAddSignatureText', info='idem')
669
request_handlers.register_lazy(
670
'Repository.all_revision_ids', 'bzrlib.smart.repository',
671
'SmartServerRepositoryAllRevisionIds', info='read')
594
672
request_handlers.register_lazy(
595
673
'PackRepository.autopack', 'bzrlib.smart.packrepository',
596
'SmartServerPackRepositoryAutopack')
597
request_handlers.register_lazy('Repository.gather_stats',
598
'bzrlib.smart.repository',
599
'SmartServerRepositoryGatherStats')
600
request_handlers.register_lazy('Repository.get_parent_map',
601
'bzrlib.smart.repository',
602
'SmartServerRepositoryGetParentMap')
603
request_handlers.register_lazy(
604
'Repository.get_revision_graph', 'bzrlib.smart.repository', 'SmartServerRepositoryGetRevisionGraph')
605
request_handlers.register_lazy(
606
'Repository.has_revision', 'bzrlib.smart.repository', 'SmartServerRequestHasRevision')
607
request_handlers.register_lazy(
608
'Repository.insert_stream', 'bzrlib.smart.repository', 'SmartServerRepositoryInsertStream')
609
request_handlers.register_lazy(
610
'Repository.insert_stream_1.19', 'bzrlib.smart.repository', 'SmartServerRepositoryInsertStream_1_19')
611
request_handlers.register_lazy(
612
'Repository.insert_stream_locked', 'bzrlib.smart.repository', 'SmartServerRepositoryInsertStreamLocked')
613
request_handlers.register_lazy(
614
'Repository.is_shared', 'bzrlib.smart.repository', 'SmartServerRepositoryIsShared')
615
request_handlers.register_lazy(
616
'Repository.lock_write', 'bzrlib.smart.repository', 'SmartServerRepositoryLockWrite')
674
'SmartServerPackRepositoryAutopack', info='idem')
675
request_handlers.register_lazy(
676
'Repository.break_lock', 'bzrlib.smart.repository',
677
'SmartServerRepositoryBreakLock', info='idem')
678
request_handlers.register_lazy(
679
'Repository.gather_stats', 'bzrlib.smart.repository',
680
'SmartServerRepositoryGatherStats', info='read')
681
request_handlers.register_lazy(
682
'Repository.get_parent_map', 'bzrlib.smart.repository',
683
'SmartServerRepositoryGetParentMap', info='read')
684
request_handlers.register_lazy(
685
'Repository.get_revision_graph', 'bzrlib.smart.repository',
686
'SmartServerRepositoryGetRevisionGraph', info='read')
687
request_handlers.register_lazy(
688
'Repository.get_revision_signature_text', 'bzrlib.smart.repository',
689
'SmartServerRepositoryGetRevisionSignatureText', info='read')
690
request_handlers.register_lazy(
691
'Repository.has_revision', 'bzrlib.smart.repository',
692
'SmartServerRequestHasRevision', info='read')
693
request_handlers.register_lazy(
694
'Repository.has_signature_for_revision_id', 'bzrlib.smart.repository',
695
'SmartServerRequestHasSignatureForRevisionId', info='read')
696
request_handlers.register_lazy(
697
'Repository.insert_stream', 'bzrlib.smart.repository',
698
'SmartServerRepositoryInsertStream', info='stream')
699
request_handlers.register_lazy(
700
'Repository.insert_stream_1.19', 'bzrlib.smart.repository',
701
'SmartServerRepositoryInsertStream_1_19', info='stream')
702
request_handlers.register_lazy(
703
'Repository.insert_stream_locked', 'bzrlib.smart.repository',
704
'SmartServerRepositoryInsertStreamLocked', info='stream')
705
request_handlers.register_lazy(
706
'Repository.is_shared', 'bzrlib.smart.repository',
707
'SmartServerRepositoryIsShared', info='read')
708
request_handlers.register_lazy(
709
'Repository.iter_files_bytes', 'bzrlib.smart.repository',
710
'SmartServerRepositoryIterFilesBytes', info='read')
711
request_handlers.register_lazy(
712
'Repository.lock_write', 'bzrlib.smart.repository',
713
'SmartServerRepositoryLockWrite', info='semi')
714
request_handlers.register_lazy(
715
'Repository.make_working_trees', 'bzrlib.smart.repository',
716
'SmartServerRepositoryMakeWorkingTrees', info='read')
617
717
request_handlers.register_lazy(
618
718
'Repository.set_make_working_trees', 'bzrlib.smart.repository',
619
'SmartServerRepositorySetMakeWorkingTrees')
620
request_handlers.register_lazy(
621
'Repository.unlock', 'bzrlib.smart.repository', 'SmartServerRepositoryUnlock')
719
'SmartServerRepositorySetMakeWorkingTrees', info='idem')
720
request_handlers.register_lazy(
721
'Repository.unlock', 'bzrlib.smart.repository',
722
'SmartServerRepositoryUnlock', info='semi')
723
request_handlers.register_lazy(
724
'Repository.get_physical_lock_status', 'bzrlib.smart.repository',
725
'SmartServerRepositoryGetPhysicalLockStatus', info='read')
622
726
request_handlers.register_lazy(
623
727
'Repository.get_rev_id_for_revno', 'bzrlib.smart.repository',
624
'SmartServerRepositoryGetRevIdForRevno')
728
'SmartServerRepositoryGetRevIdForRevno', info='read')
625
729
request_handlers.register_lazy(
626
730
'Repository.get_stream', 'bzrlib.smart.repository',
627
'SmartServerRepositoryGetStream')
731
'SmartServerRepositoryGetStream', info='read')
628
732
request_handlers.register_lazy(
629
733
'Repository.get_stream_1.19', 'bzrlib.smart.repository',
630
'SmartServerRepositoryGetStream_1_19')
734
'SmartServerRepositoryGetStream_1_19', info='read')
735
request_handlers.register_lazy(
736
'Repository.iter_revisions', 'bzrlib.smart.repository',
737
'SmartServerRepositoryIterRevisions', info='read')
738
request_handlers.register_lazy(
739
'Repository.pack', 'bzrlib.smart.repository',
740
'SmartServerRepositoryPack', info='idem')
741
request_handlers.register_lazy(
742
'Repository.start_write_group', 'bzrlib.smart.repository',
743
'SmartServerRepositoryStartWriteGroup', info='semi')
744
request_handlers.register_lazy(
745
'Repository.commit_write_group', 'bzrlib.smart.repository',
746
'SmartServerRepositoryCommitWriteGroup', info='semi')
747
request_handlers.register_lazy(
748
'Repository.abort_write_group', 'bzrlib.smart.repository',
749
'SmartServerRepositoryAbortWriteGroup', info='semi')
750
request_handlers.register_lazy(
751
'Repository.check_write_group', 'bzrlib.smart.repository',
752
'SmartServerRepositoryCheckWriteGroup', info='read')
753
request_handlers.register_lazy(
754
'Repository.reconcile', 'bzrlib.smart.repository',
755
'SmartServerRepositoryReconcile', info='idem')
631
756
request_handlers.register_lazy(
632
757
'Repository.tarball', 'bzrlib.smart.repository',
633
'SmartServerRepositoryTarball')
634
request_handlers.register_lazy(
635
'rmdir', 'bzrlib.smart.vfs', 'RmdirRequest')
636
request_handlers.register_lazy(
637
'stat', 'bzrlib.smart.vfs', 'StatRequest')
638
request_handlers.register_lazy(
639
'Transport.is_readonly', 'bzrlib.smart.request', 'SmartServerIsReadonly')
758
'SmartServerRepositoryTarball', info='read')
759
request_handlers.register_lazy(
760
'VersionedFileRepository.get_serializer_format', 'bzrlib.smart.repository',
761
'SmartServerRepositoryGetSerializerFormat', info='read')
762
request_handlers.register_lazy(
763
'VersionedFileRepository.get_inventories', 'bzrlib.smart.repository',
764
'SmartServerRepositoryGetInventories', info='read')
765
request_handlers.register_lazy(
766
'rmdir', 'bzrlib.smart.vfs', 'RmdirRequest', info='semivfs')
767
request_handlers.register_lazy(
768
'stat', 'bzrlib.smart.vfs', 'StatRequest', info='read')
769
request_handlers.register_lazy(
770
'Transport.is_readonly', 'bzrlib.smart.request',
771
'SmartServerIsReadonly', info='read')