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