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