Rev 4687: (andrew) Remove SmartServerRequest.dispatch_command, in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Mon Sep 14 02:48:22 BST 2009


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 4687 [merge]
revision-id: pqm at pqm.ubuntu.com-20090914014819-4yshlf6ooeeqznfs
parent: pqm at pqm.ubuntu.com-20090913114736-13k4s1i0b62l6sno
parent: andrew.bennetts at canonical.com-20090911060705-n4im56d54nlkwcqb
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2009-09-14 02:48:19 +0100
message:
  (andrew) Remove SmartServerRequest.dispatch_command,
  	fix SmartServerRequest.args_received.
modified:
  bzrlib/smart/message.py        message.py-20080222013625-ncqmh3nrxjkxab87-1
  bzrlib/smart/protocol.py       protocol.py-20061108035435-ot0lstk2590yqhzr-1
  bzrlib/smart/request.py        request.py-20061108095550-gunadhxmzkdjfeek-1
  bzrlib/tests/test_smart_transport.py test_ssh_transport.py-20060608202016-c25gvf1ob7ypbus6-2
=== modified file 'bzrlib/smart/message.py'
--- a/bzrlib/smart/message.py	2009-07-28 22:27:04 +0000
+++ b/bzrlib/smart/message.py	2009-09-11 06:07:05 +0000
@@ -134,7 +134,7 @@
 
     def _args_received(self, args):
         self.expecting = 'body'
-        self.request_handler.dispatch_command(args[0], args[1:])
+        self.request_handler.args_received(args)
         if self.request_handler.finished_reading:
             self._response_sent = True
             self.responder.send_response(self.request_handler.response)

=== modified file 'bzrlib/smart/protocol.py'
--- a/bzrlib/smart/protocol.py	2009-07-21 03:11:33 +0000
+++ b/bzrlib/smart/protocol.py	2009-09-11 06:07:05 +0000
@@ -145,7 +145,7 @@
                 self.request = request.SmartServerRequestHandler(
                     self._backing_transport, commands=request.request_handlers,
                     root_client_path=self._root_client_path)
-                self.request.dispatch_command(req_args[0], req_args[1:])
+                self.request.args_received(req_args)
                 if self.request.finished_reading:
                     # trivial request
                     self.unused_data = self.in_buffer

=== modified file 'bzrlib/smart/request.py'
--- a/bzrlib/smart/request.py	2009-08-30 21:34:42 +0000
+++ b/bzrlib/smart/request.py	2009-09-14 01:48:19 +0000
@@ -292,15 +292,6 @@
         # cannot read after this.
         self.finished_reading = True
 
-    def dispatch_command(self, cmd, args):
-        """Deprecated compatibility method.""" # XXX XXX
-        try:
-            command = self._commands.get(cmd)
-        except LookupError:
-            raise errors.UnknownSmartMethod(cmd)
-        self._command = command(self._backing_transport, self._root_client_path)
-        self._run_handler_code(self._command.execute, args, {})
-
     def _run_handler_code(self, callable, args, kwargs):
         """Run some handler specific code 'callable'.
 
@@ -343,7 +334,8 @@
             command = self._commands.get(cmd)
         except LookupError:
             raise errors.UnknownSmartMethod(cmd)
-        self._command = command(self._backing_transport)
+        self._command = command(
+            self._backing_transport, self._root_client_path)
         self._run_handler_code(self._command.execute, args, {})
 
     def end_received(self):

=== modified file 'bzrlib/tests/test_smart_transport.py'
--- a/bzrlib/tests/test_smart_transport.py	2009-09-07 09:05:02 +0000
+++ b/bzrlib/tests/test_smart_transport.py	2009-09-14 01:48:19 +0000
@@ -1248,7 +1248,7 @@
 
     def test_hello(self):
         handler = self.build_handler(None)
-        handler.dispatch_command('hello', ())
+        handler.args_received(('hello',))
         self.assertEqual(('ok', '2'), handler.response.args)
         self.assertEqual(None, handler.response.body)
 
@@ -1268,7 +1268,7 @@
         """The response for a read-only error is ('ReadOnlyError')."""
         handler = self.build_handler(self.get_readonly_transport())
         # send a mkdir for foo, with no explicit mode - should fail.
-        handler.dispatch_command('mkdir', ('foo', ''))
+        handler.args_received(('mkdir', 'foo', ''))
         # and the failure should be an explicit ReadOnlyError
         self.assertEqual(("ReadOnlyError", ), handler.response.args)
         # XXX: TODO: test that other TransportNotPossible errors are
@@ -1279,14 +1279,14 @@
     def test_hello_has_finished_body_on_dispatch(self):
         """The 'hello' command should set finished_reading."""
         handler = self.build_handler(None)
-        handler.dispatch_command('hello', ())
+        handler.args_received(('hello',))
         self.assertTrue(handler.finished_reading)
         self.assertNotEqual(None, handler.response)
 
     def test_put_bytes_non_atomic(self):
         """'put_...' should set finished_reading after reading the bytes."""
         handler = self.build_handler(self.get_transport())
-        handler.dispatch_command('put_non_atomic', ('a-file', '', 'F', ''))
+        handler.args_received(('put_non_atomic', 'a-file', '', 'F', ''))
         self.assertFalse(handler.finished_reading)
         handler.accept_body('1234')
         self.assertFalse(handler.finished_reading)
@@ -1300,7 +1300,7 @@
         """'readv' should set finished_reading after reading offsets."""
         self.build_tree(['a-file'])
         handler = self.build_handler(self.get_readonly_transport())
-        handler.dispatch_command('readv', ('a-file', ))
+        handler.args_received(('readv', 'a-file'))
         self.assertFalse(handler.finished_reading)
         handler.accept_body('2,')
         self.assertFalse(handler.finished_reading)
@@ -1315,7 +1315,7 @@
         """'readv' when a short read occurs sets the response appropriately."""
         self.build_tree(['a-file'])
         handler = self.build_handler(self.get_readonly_transport())
-        handler.dispatch_command('readv', ('a-file', ))
+        handler.args_received(('readv', 'a-file'))
         # read beyond the end of the file.
         handler.accept_body('100,1')
         handler.end_of_body()
@@ -2542,8 +2542,8 @@
         self.calls.append(('end_received',))
         self.finished_reading = True
 
-    def dispatch_command(self, cmd, args):
-        self.calls.append(('dispatch_command', cmd, args))
+    def args_received(self, args):
+        self.calls.append(('args_received', args))
 
     def accept_body(self, bytes):
         self.calls.append(('accept_body', bytes))




More information about the bazaar-commits mailing list