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