Rev 4907: Per request, change in http://bazaar.launchpad.net/~jameinel/bzr/2.1-categorize-requests-819604

John Arbash Meinel john at arbash-meinel.com
Mon Oct 10 11:23:41 UTC 2011


At http://bazaar.launchpad.net/~jameinel/bzr/2.1-categorize-requests-819604

------------------------------------------------------------
revno: 4907
revision-id: john at arbash-meinel.com-20111010112323-j6aqp068qxhefoi8
parent: john at arbash-meinel.com-20111008114800-ldcbe9fr0wqs7dkm
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1-categorize-requests-819604
timestamp: Mon 2011-10-10 13:23:23 +0200
message:
  Per request, change 
  
  safe gets split into 'idem' for an idempotent write request, and 'read' for
  a readonly request.
  unsafe becomes 'mutate'
  semi gets split into 'semivfs' so that we can single out VFS requests that
  we want to treat as unsafe.
-------------- next part --------------
=== modified file 'bzrlib/smart/request.py'
--- a/bzrlib/smart/request.py	2011-10-08 11:48:00 +0000
+++ b/bzrlib/smart/request.py	2011-10-10 11:23:23 +0000
@@ -488,14 +488,12 @@
 
 # In the 'info' attribute, we store whether this request is 'safe' to retry if
 # we get a disconnect while reading the response. It can have the values:
-#   safe    The request is strictly idempotent, calling it twice results in
-#           the same result as calling it one time. This includes all read-only
-#           requests, and write requests like 'put' where the end result is
-#           identical content.
-#   unsafe  A request which is unsafe means that state is updated in a way that
-#           replaying that request results in a different state. For example
-#           'append' writes more bytes to a given file. If append succeeds, it
-#           moves the file pointer.
+#   read    This is purely a read request, so retrying it is perfectly ok.
+#   idem    An idempotent write request. Something like 'put' where if you put
+#           the same bytes twice you end up with the same final bytes.
+#   mutate  State is updated in a way that replaying that request results in a
+#           different state. For example 'append' writes more bytes to a given
+#           file. If append succeeds, it moves the file pointer.
 #   semi    This is a request that isn't strictly idempotent, but doesn't
 #           result in corruption if it is retried. This is for things like
 #           'lock' and 'unlock'. If you call lock, it updates the disk
@@ -507,58 +505,58 @@
 #           want. If it did, we will interrupt the current operation, but we
 #           are no worse off than interrupting the current operation because of
 #           a ConnectionReset.
+#   semivfs Similar to semi, but specific to a Virtual FileSystem request.
 #   stream  This is a request that takes a stream that cannot be restarted if
 #           consumed. This request is 'safe' in that if we determine the
 #           connection is closed before we consume the stream, we can try
 #           again.
 request_handlers = registry.Registry()
 request_handlers.register_lazy(
-    'append', 'bzrlib.smart.vfs', 'AppendRequest', info='unsafe')
+    'append', 'bzrlib.smart.vfs', 'AppendRequest', info='mutate')
 request_handlers.register_lazy(
     'Branch.get_config_file', 'bzrlib.smart.branch',
-    'SmartServerBranchGetConfigFile', info='safe')
+    'SmartServerBranchGetConfigFile', info='read')
 request_handlers.register_lazy(
     'Branch.get_parent', 'bzrlib.smart.branch', 'SmartServerBranchGetParent',
-    info='safe')
+    info='read')
 request_handlers.register_lazy(
     'Branch.get_tags_bytes', 'bzrlib.smart.branch',
-    'SmartServerBranchGetTagsBytes', info='safe')
+    'SmartServerBranchGetTagsBytes', info='read')
 request_handlers.register_lazy(
     'Branch.set_tags_bytes', 'bzrlib.smart.branch',
-    'SmartServerBranchSetTagsBytes', info='safe')
+    'SmartServerBranchSetTagsBytes', info='idem')
 request_handlers.register_lazy(
     'Branch.get_stacked_on_url', 'bzrlib.smart.branch',
-    'SmartServerBranchRequestGetStackedOnURL', info='safe')
+    'SmartServerBranchRequestGetStackedOnURL', info='read')
 request_handlers.register_lazy(
     'Branch.last_revision_info', 'bzrlib.smart.branch',
-    'SmartServerBranchRequestLastRevisionInfo', info='safe')
+    'SmartServerBranchRequestLastRevisionInfo', info='read')
 request_handlers.register_lazy(
     'Branch.lock_write', 'bzrlib.smart.branch',
     'SmartServerBranchRequestLockWrite', info='semi')
 request_handlers.register_lazy( 'Branch.revision_history',
-    'bzrlib.smart.branch', 'SmartServerRequestRevisionHistory',
-    info='safe')
-request_handlers.register_lazy( 'Branch.set_config_option',
-    'bzrlib.smart.branch', 'SmartServerBranchRequestSetConfigOption',
-    info='safe')
-request_handlers.register_lazy( 'Branch.set_last_revision',
-    'bzrlib.smart.branch', 'SmartServerBranchRequestSetLastRevision',
-    info='safe')
+    'bzrlib.smart.branch', 'SmartServerRequestRevisionHistory', info='read')
+request_handlers.register_lazy(
+    'Branch.set_config_option', 'bzrlib.smart.branch',
+    'SmartServerBranchRequestSetConfigOption', info='idem')
+request_handlers.register_lazy(
+    'Branch.set_last_revision', 'bzrlib.smart.branch',
+    'SmartServerBranchRequestSetLastRevision', info='idem')
 request_handlers.register_lazy(
     'Branch.set_last_revision_info', 'bzrlib.smart.branch',
-    'SmartServerBranchRequestSetLastRevisionInfo', info='safe')
+    'SmartServerBranchRequestSetLastRevisionInfo', info='idem')
 request_handlers.register_lazy(
     'Branch.set_last_revision_ex', 'bzrlib.smart.branch',
-    'SmartServerBranchRequestSetLastRevisionEx', info='safe')
+    'SmartServerBranchRequestSetLastRevisionEx', info='idem')
 request_handlers.register_lazy(
     'Branch.set_parent_location', 'bzrlib.smart.branch',
-    'SmartServerBranchRequestSetParentLocation', info='safe')
+    'SmartServerBranchRequestSetParentLocation', info='idem')
 request_handlers.register_lazy(
     'Branch.unlock', 'bzrlib.smart.branch', 'SmartServerBranchRequestUnlock',
-    info='safe')
+    info='semi')
 request_handlers.register_lazy(
     'BzrDir.cloning_metadir', 'bzrlib.smart.bzrdir',
-    'SmartServerBzrDirRequestCloningMetaDir', info='safe')
+    'SmartServerBzrDirRequestCloningMetaDir', info='read')
 request_handlers.register_lazy(
     'BzrDir.create_branch', 'bzrlib.smart.bzrdir',
     'SmartServerRequestCreateBranch', info='semi')
@@ -567,16 +565,16 @@
     'SmartServerRequestCreateRepository', info='semi')
 request_handlers.register_lazy(
     'BzrDir.find_repository', 'bzrlib.smart.bzrdir',
-    'SmartServerRequestFindRepositoryV1', info='safe')
+    'SmartServerRequestFindRepositoryV1', info='read')
 request_handlers.register_lazy(
     'BzrDir.find_repositoryV2', 'bzrlib.smart.bzrdir',
-    'SmartServerRequestFindRepositoryV2', info='safe')
+    'SmartServerRequestFindRepositoryV2', info='read')
 request_handlers.register_lazy(
     'BzrDir.find_repositoryV3', 'bzrlib.smart.bzrdir',
-    'SmartServerRequestFindRepositoryV3', info='safe')
+    'SmartServerRequestFindRepositoryV3', info='read')
 request_handlers.register_lazy(
     'BzrDir.get_config_file', 'bzrlib.smart.bzrdir',
-    'SmartServerBzrDirRequestConfigFile', info='safe')
+    'SmartServerBzrDirRequestConfigFile', info='read')
 request_handlers.register_lazy(
     'BzrDirFormat.initialize', 'bzrlib.smart.bzrdir',
     'SmartServerRequestInitializeBzrDir', info='semi')
@@ -585,61 +583,61 @@
     'SmartServerRequestBzrDirInitializeEx', info='semi')
 request_handlers.register_lazy(
     'BzrDir.open', 'bzrlib.smart.bzrdir', 'SmartServerRequestOpenBzrDir',
-    info='safe')
+    info='read')
 request_handlers.register_lazy(
     'BzrDir.open_2.1', 'bzrlib.smart.bzrdir',
-    'SmartServerRequestOpenBzrDir_2_1', info='safe')
+    'SmartServerRequestOpenBzrDir_2_1', info='read')
 request_handlers.register_lazy(
     'BzrDir.open_branch', 'bzrlib.smart.bzrdir',
-    'SmartServerRequestOpenBranch', info='safe')
+    'SmartServerRequestOpenBranch', info='read')
 request_handlers.register_lazy(
     'BzrDir.open_branchV2', 'bzrlib.smart.bzrdir',
-    'SmartServerRequestOpenBranchV2', info='safe')
+    'SmartServerRequestOpenBranchV2', info='read')
 request_handlers.register_lazy(
     'BzrDir.open_branchV3', 'bzrlib.smart.bzrdir',
-    'SmartServerRequestOpenBranchV3', info='safe')
-request_handlers.register_lazy(
-    'delete', 'bzrlib.smart.vfs', 'DeleteRequest', info='semi')
-request_handlers.register_lazy(
-    'get', 'bzrlib.smart.vfs', 'GetRequest', info='safe')
-request_handlers.register_lazy(
-    'get_bundle', 'bzrlib.smart.request', 'GetBundleRequest', info='safe')
-request_handlers.register_lazy(
-    'has', 'bzrlib.smart.vfs', 'HasRequest', info='safe')
-request_handlers.register_lazy(
-    'hello', 'bzrlib.smart.request', 'HelloRequest', info='safe')
+    'SmartServerRequestOpenBranchV3', info='read')
+request_handlers.register_lazy(
+    'delete', 'bzrlib.smart.vfs', 'DeleteRequest', info='semivfs')
+request_handlers.register_lazy(
+    'get', 'bzrlib.smart.vfs', 'GetRequest', info='read')
+request_handlers.register_lazy(
+    'get_bundle', 'bzrlib.smart.request', 'GetBundleRequest', info='read')
+request_handlers.register_lazy(
+    'has', 'bzrlib.smart.vfs', 'HasRequest', info='read')
+request_handlers.register_lazy(
+    'hello', 'bzrlib.smart.request', 'HelloRequest', info='read')
 request_handlers.register_lazy(
     'iter_files_recursive', 'bzrlib.smart.vfs', 'IterFilesRecursiveRequest',
-    info='safe')
-request_handlers.register_lazy(
-    'list_dir', 'bzrlib.smart.vfs', 'ListDirRequest', info='safe')
-request_handlers.register_lazy(
-    'mkdir', 'bzrlib.smart.vfs', 'MkdirRequest', info='semi')
-request_handlers.register_lazy(
-    'move', 'bzrlib.smart.vfs', 'MoveRequest', info='semi')
-request_handlers.register_lazy(
-    'put', 'bzrlib.smart.vfs', 'PutRequest', info='safe')
-request_handlers.register_lazy(
-    'put_non_atomic', 'bzrlib.smart.vfs', 'PutNonAtomicRequest', info='safe')
-request_handlers.register_lazy(
-    'readv', 'bzrlib.smart.vfs', 'ReadvRequest', info='safe')
-request_handlers.register_lazy(
-    'rename', 'bzrlib.smart.vfs', 'RenameRequest', info='semi')
+    info='read')
+request_handlers.register_lazy(
+    'list_dir', 'bzrlib.smart.vfs', 'ListDirRequest', info='read')
+request_handlers.register_lazy(
+    'mkdir', 'bzrlib.smart.vfs', 'MkdirRequest', info='semivfs')
+request_handlers.register_lazy(
+    'move', 'bzrlib.smart.vfs', 'MoveRequest', info='semivfs')
+request_handlers.register_lazy(
+    'put', 'bzrlib.smart.vfs', 'PutRequest', info='idem')
+request_handlers.register_lazy(
+    'put_non_atomic', 'bzrlib.smart.vfs', 'PutNonAtomicRequest', info='idem')
+request_handlers.register_lazy(
+    'readv', 'bzrlib.smart.vfs', 'ReadvRequest', info='read')
+request_handlers.register_lazy(
+    'rename', 'bzrlib.smart.vfs', 'RenameRequest', info='semivfs')
 request_handlers.register_lazy(
     'PackRepository.autopack', 'bzrlib.smart.packrepository',
-    'SmartServerPackRepositoryAutopack', info='safe')
+    'SmartServerPackRepositoryAutopack', info='idem')
 request_handlers.register_lazy(
     'Repository.gather_stats', 'bzrlib.smart.repository',
-    'SmartServerRepositoryGatherStats', info='safe')
+    'SmartServerRepositoryGatherStats', info='read')
 request_handlers.register_lazy(
     'Repository.get_parent_map', 'bzrlib.smart.repository',
-    'SmartServerRepositoryGetParentMap', info='safe')
+    'SmartServerRepositoryGetParentMap', info='read')
 request_handlers.register_lazy(
     'Repository.get_revision_graph', 'bzrlib.smart.repository',
-    'SmartServerRepositoryGetRevisionGraph', info='safe')
+    'SmartServerRepositoryGetRevisionGraph', info='read')
 request_handlers.register_lazy(
     'Repository.has_revision', 'bzrlib.smart.repository',
-    'SmartServerRequestHasRevision', info='safe')
+    'SmartServerRequestHasRevision', info='read')
 request_handlers.register_lazy(
     'Repository.insert_stream', 'bzrlib.smart.repository',
     'SmartServerRepositoryInsertStream', info='stream')
@@ -651,32 +649,32 @@
     'SmartServerRepositoryInsertStreamLocked', info='stream')
 request_handlers.register_lazy(
     'Repository.is_shared', 'bzrlib.smart.repository',
-    'SmartServerRepositoryIsShared', info='safe')
+    'SmartServerRepositoryIsShared', info='read')
 request_handlers.register_lazy(
     'Repository.lock_write', 'bzrlib.smart.repository',
     'SmartServerRepositoryLockWrite', info='semi')
 request_handlers.register_lazy(
     'Repository.set_make_working_trees', 'bzrlib.smart.repository',
-    'SmartServerRepositorySetMakeWorkingTrees', info='safe')
+    'SmartServerRepositorySetMakeWorkingTrees', info='idem')
 request_handlers.register_lazy(
     'Repository.unlock', 'bzrlib.smart.repository',
     'SmartServerRepositoryUnlock', info='semi')
 request_handlers.register_lazy(
     'Repository.get_rev_id_for_revno', 'bzrlib.smart.repository',
-    'SmartServerRepositoryGetRevIdForRevno', info='safe')
+    'SmartServerRepositoryGetRevIdForRevno', info='read')
 request_handlers.register_lazy(
     'Repository.get_stream', 'bzrlib.smart.repository',
-    'SmartServerRepositoryGetStream', info='safe')
+    'SmartServerRepositoryGetStream', info='read')
 request_handlers.register_lazy(
     'Repository.get_stream_1.19', 'bzrlib.smart.repository',
-    'SmartServerRepositoryGetStream_1_19', info='safe')
+    'SmartServerRepositoryGetStream_1_19', info='read')
 request_handlers.register_lazy(
     'Repository.tarball', 'bzrlib.smart.repository',
-    'SmartServerRepositoryTarball', info='safe')
-request_handlers.register_lazy(
-    'rmdir', 'bzrlib.smart.vfs', 'RmdirRequest', info='semi')
-request_handlers.register_lazy(
-    'stat', 'bzrlib.smart.vfs', 'StatRequest', info='safe')
+    'SmartServerRepositoryTarball', info='read')
+request_handlers.register_lazy(
+    'rmdir', 'bzrlib.smart.vfs', 'RmdirRequest', info='semivfs')
+request_handlers.register_lazy(
+    'stat', 'bzrlib.smart.vfs', 'StatRequest', info='read')
 request_handlers.register_lazy(
     'Transport.is_readonly', 'bzrlib.smart.request', 'SmartServerIsReadonly',
-    info='safe')
+    info='read')

=== modified file 'bzrlib/tests/test_smart_request.py'
--- a/bzrlib/tests/test_smart_request.py	2011-10-08 11:48:00 +0000
+++ b/bzrlib/tests/test_smart_request.py	2011-10-10 11:23:23 +0000
@@ -111,15 +111,14 @@
 
     def test_all_registered_requests_are_safety_qualified(self):
         unclassified_requests = []
+        allowed_info = ('read', 'idem', 'mutate', 'semivfs', 'semi', 'stream')
         for key in request.request_handlers.keys():
             info = request.request_handlers.get_info(key)
-            if info is None or info not in ('safe', 'unsafe', 'semi', 'stream'):
+            if info is None or info not in allowed_info:
                 unclassified_requests.append(key)
         if unclassified_requests:
             self.fail('These requests were not categorized as safe/unsafe'
                       ' to retry: %s'  % (unclassified_requests,))
-        
-
 
 
 class TestSmartRequestHandlerErrorTranslation(TestCase):



More information about the bazaar-commits mailing list