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