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