diff mercurial/wireprotoserver.py @ 36073:cd6ab329c5c7

wireprototypes: move wire protocol response types to new module We'll be introducing more types as part of wire protocol version 2. These types are shared between the command handling code (in wireproto.py) and the protocol/transport code in wireprotoserver.py. So they need to go in a new module to prevent a cycle. The types are aliased into the wireproto module, so API compatibility is preserved. Differential Revision: https://phab.mercurial-scm.org/D2088
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 07 Feb 2018 16:29:05 -0800
parents 341c886e411e
children 2f7290555c96
line wrap: on
line diff
--- a/mercurial/wireprotoserver.py	Thu Feb 01 16:59:18 2018 -0800
+++ b/mercurial/wireprotoserver.py	Wed Feb 07 16:29:05 2018 -0800
@@ -20,6 +20,7 @@
     pycompat,
     util,
     wireproto,
+    wireprototypes,
 )
 
 stringio = util.stringio
@@ -273,11 +274,11 @@
     if isinstance(rsp, bytes):
         req.respond(HTTP_OK, HGTYPE, body=rsp)
         return []
-    elif isinstance(rsp, wireproto.streamres_legacy):
+    elif isinstance(rsp, wireprototypes.streamreslegacy):
         gen = rsp.gen
         req.respond(HTTP_OK, HGTYPE)
         return gen
-    elif isinstance(rsp, wireproto.streamres):
+    elif isinstance(rsp, wireprototypes.streamres):
         gen = rsp.gen
 
         # This code for compression should not be streamres specific. It
@@ -291,18 +292,18 @@
 
         req.respond(HTTP_OK, mediatype)
         return gen
-    elif isinstance(rsp, wireproto.pushres):
+    elif isinstance(rsp, wireprototypes.pushres):
         rsp = '%d\n%s' % (rsp.res, rsp.output)
         req.respond(HTTP_OK, HGTYPE, body=rsp)
         return []
-    elif isinstance(rsp, wireproto.pusherr):
+    elif isinstance(rsp, wireprototypes.pusherr):
         # This is the httplib workaround documented in _handlehttperror().
         req.drain()
 
         rsp = '0\n%s\n' % rsp.res
         req.respond(HTTP_OK, HGTYPE, body=rsp)
         return []
-    elif isinstance(rsp, wireproto.ooberror):
+    elif isinstance(rsp, wireprototypes.ooberror):
         rsp = rsp.message
         req.respond(HTTP_OK, HGERRTYPE, body=rsp)
         return []
@@ -434,16 +435,16 @@
 
             if isinstance(rsp, bytes):
                 _sshv1respondbytes(self._fout, rsp)
-            elif isinstance(rsp, wireproto.streamres):
+            elif isinstance(rsp, wireprototypes.streamres):
                 _sshv1respondstream(self._fout, rsp)
-            elif isinstance(rsp, wireproto.streamres_legacy):
+            elif isinstance(rsp, wireprototypes.streamreslegacy):
                 _sshv1respondstream(self._fout, rsp)
-            elif isinstance(rsp, wireproto.pushres):
+            elif isinstance(rsp, wireprototypes.pushres):
                 _sshv1respondbytes(self._fout, b'')
                 _sshv1respondbytes(self._fout, bytes(rsp.res))
-            elif isinstance(rsp, wireproto.pusherr):
+            elif isinstance(rsp, wireprototypes.pusherr):
                 _sshv1respondbytes(self._fout, rsp.res)
-            elif isinstance(rsp, wireproto.ooberror):
+            elif isinstance(rsp, wireprototypes.ooberror):
                 _sshv1respondooberror(self._fout, self._ui.ferr, rsp.message)
             else:
                 raise error.ProgrammingError('unhandled response type from '