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')
528
585
request_handlers.register_lazy(
529
586
'BzrDir.cloning_metadir', 'bzrlib.smart.bzrdir',
530
'SmartServerBzrDirRequestCloningMetaDir')
587
'SmartServerBzrDirRequestCloningMetaDir', info='read')
531
588
request_handlers.register_lazy(
532
589
'BzrDir.create_branch', 'bzrlib.smart.bzrdir',
533
'SmartServerRequestCreateBranch')
590
'SmartServerRequestCreateBranch', info='semi')
534
591
request_handlers.register_lazy(
535
592
'BzrDir.create_repository', 'bzrlib.smart.bzrdir',
536
'SmartServerRequestCreateRepository')
593
'SmartServerRequestCreateRepository', info='semi')
537
594
request_handlers.register_lazy(
538
595
'BzrDir.find_repository', 'bzrlib.smart.bzrdir',
539
'SmartServerRequestFindRepositoryV1')
596
'SmartServerRequestFindRepositoryV1', info='read')
540
597
request_handlers.register_lazy(
541
598
'BzrDir.find_repositoryV2', 'bzrlib.smart.bzrdir',
542
'SmartServerRequestFindRepositoryV2')
599
'SmartServerRequestFindRepositoryV2', info='read')
543
600
request_handlers.register_lazy(
544
601
'BzrDir.find_repositoryV3', 'bzrlib.smart.bzrdir',
545
'SmartServerRequestFindRepositoryV3')
602
'SmartServerRequestFindRepositoryV3', info='read')
546
603
request_handlers.register_lazy(
547
604
'BzrDir.get_config_file', 'bzrlib.smart.bzrdir',
548
'SmartServerBzrDirRequestConfigFile')
605
'SmartServerBzrDirRequestConfigFile', info='read')
606
request_handlers.register_lazy(
607
'BzrDir.destroy_branch', 'bzrlib.smart.bzrdir',
608
'SmartServerBzrDirRequestDestroyBranch', info='semi')
609
request_handlers.register_lazy(
610
'BzrDir.destroy_repository', 'bzrlib.smart.bzrdir',
611
'SmartServerBzrDirRequestDestroyRepository', info='semi')
612
request_handlers.register_lazy(
613
'BzrDir.has_workingtree', 'bzrlib.smart.bzrdir',
614
'SmartServerBzrDirRequestHasWorkingTree', info='read')
549
615
request_handlers.register_lazy(
550
616
'BzrDirFormat.initialize', 'bzrlib.smart.bzrdir',
551
'SmartServerRequestInitializeBzrDir')
617
'SmartServerRequestInitializeBzrDir', info='semi')
552
618
request_handlers.register_lazy(
553
619
'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')
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')
559
627
request_handlers.register_lazy(
560
628
'BzrDir.open_branch', 'bzrlib.smart.bzrdir',
561
'SmartServerRequestOpenBranch')
629
'SmartServerRequestOpenBranch', info='read')
562
630
request_handlers.register_lazy(
563
631
'BzrDir.open_branchV2', 'bzrlib.smart.bzrdir',
564
'SmartServerRequestOpenBranchV2')
632
'SmartServerRequestOpenBranchV2', info='read')
565
633
request_handlers.register_lazy(
566
634
'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')
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')
594
669
request_handlers.register_lazy(
595
670
'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')
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')
684
request_handlers.register_lazy(
685
'Repository.get_revision_signature_text', 'bzrlib.smart.repository',
686
'SmartServerRepositoryGetRevisionSignatureText', info='read')
687
request_handlers.register_lazy(
688
'Repository.has_revision', 'bzrlib.smart.repository',
689
'SmartServerRequestHasRevision', info='read')
690
request_handlers.register_lazy(
691
'Repository.has_signature_for_revision_id', 'bzrlib.smart.repository',
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')
705
request_handlers.register_lazy(
706
'Repository.iter_files_bytes', 'bzrlib.smart.repository',
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')
617
714
request_handlers.register_lazy(
618
715
'Repository.set_make_working_trees', 'bzrlib.smart.repository',
619
'SmartServerRepositorySetMakeWorkingTrees')
620
request_handlers.register_lazy(
621
'Repository.unlock', 'bzrlib.smart.repository', 'SmartServerRepositoryUnlock')
716
'SmartServerRepositorySetMakeWorkingTrees', info='idem')
717
request_handlers.register_lazy(
718
'Repository.unlock', 'bzrlib.smart.repository',
719
'SmartServerRepositoryUnlock', info='semi')
720
request_handlers.register_lazy(
721
'Repository.get_physical_lock_status', 'bzrlib.smart.repository',
722
'SmartServerRepositoryGetPhysicalLockStatus', info='read')
622
723
request_handlers.register_lazy(
623
724
'Repository.get_rev_id_for_revno', 'bzrlib.smart.repository',
624
'SmartServerRepositoryGetRevIdForRevno')
725
'SmartServerRepositoryGetRevIdForRevno', info='read')
625
726
request_handlers.register_lazy(
626
727
'Repository.get_stream', 'bzrlib.smart.repository',
627
'SmartServerRepositoryGetStream')
728
'SmartServerRepositoryGetStream', info='read')
628
729
request_handlers.register_lazy(
629
730
'Repository.get_stream_1.19', 'bzrlib.smart.repository',
630
'SmartServerRepositoryGetStream_1_19')
731
'SmartServerRepositoryGetStream_1_19', info='read')
732
request_handlers.register_lazy(
733
'Repository.iter_revisions', 'bzrlib.smart.repository',
734
'SmartServerRepositoryIterRevisions', info='read')
735
request_handlers.register_lazy(
736
'Repository.pack', 'bzrlib.smart.repository',
737
'SmartServerRepositoryPack', info='idem')
738
request_handlers.register_lazy(
739
'Repository.start_write_group', 'bzrlib.smart.repository',
740
'SmartServerRepositoryStartWriteGroup', info='semi')
741
request_handlers.register_lazy(
742
'Repository.commit_write_group', 'bzrlib.smart.repository',
743
'SmartServerRepositoryCommitWriteGroup', info='semi')
744
request_handlers.register_lazy(
745
'Repository.abort_write_group', 'bzrlib.smart.repository',
746
'SmartServerRepositoryAbortWriteGroup', info='semi')
747
request_handlers.register_lazy(
748
'Repository.check_write_group', 'bzrlib.smart.repository',
749
'SmartServerRepositoryCheckWriteGroup', info='read')
750
request_handlers.register_lazy(
751
'VersionedFileRepository.get_serializer_format', 'bzrlib.smart.repository',
752
'SmartServerRepositoryGetSerializerFormat', 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
'rmdir', 'bzrlib.smart.vfs', 'RmdirRequest', info='semivfs')
761
request_handlers.register_lazy(
762
'stat', 'bzrlib.smart.vfs', 'StatRequest', info='read')
763
request_handlers.register_lazy(
764
'Transport.is_readonly', 'bzrlib.smart.request',
765
'SmartServerIsReadonly', info='read')