changeset 36536:3cd245945ef3

wireprotoserver: move SSHV1 and SSHV2 constants to wireprototypes To avoid a cycle between modules in an upcoming commit. Differential Revision: https://phab.mercurial-scm.org/D2482
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 27 Feb 2018 14:26:00 -0800
parents 1c16324fdf05
children 1d99260c3a81
files mercurial/sshpeer.py mercurial/wireprotoserver.py mercurial/wireprototypes.py
diffstat 3 files changed, 15 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/sshpeer.py	Tue Feb 27 14:21:29 2018 -0800
+++ b/mercurial/sshpeer.py	Tue Feb 27 14:26:00 2018 -0800
@@ -17,6 +17,7 @@
     util,
     wireproto,
     wireprotoserver,
+    wireprototypes,
 )
 
 def _serverquote(s):
@@ -257,7 +258,7 @@
         badresponse()
 
     # Assume version 1 of wire protocol by default.
-    protoname = wireprotoserver.SSHV1
+    protoname = wireprototypes.SSHV1
     reupgraded = re.compile(b'^upgraded %s (.*)$' % re.escape(token))
 
     lines = ['', 'dummy']
@@ -296,7 +297,7 @@
 
     # For version 1, we should see a ``capabilities`` line in response to the
     # ``hello`` command.
-    if protoname == wireprotoserver.SSHV1:
+    if protoname == wireprototypes.SSHV1:
         for l in reversed(lines):
             # Look for response to ``hello`` command. Scan from the back so
             # we don't misinterpret banner output as the command reply.
@@ -555,10 +556,10 @@
         _cleanuppipes(ui, stdout, stdin, stderr)
         raise
 
-    if protoname == wireprotoserver.SSHV1:
+    if protoname == wireprototypes.SSHV1:
         return sshv1peer(ui, path, proc, stdin, stdout, stderr, caps,
                          autoreadstderr=autoreadstderr)
-    elif protoname == wireprotoserver.SSHV2:
+    elif protoname == wireprototypes.SSHV2:
         return sshv2peer(ui, path, proc, stdin, stdout, stderr, caps,
                          autoreadstderr=autoreadstderr)
     else:
--- a/mercurial/wireprotoserver.py	Tue Feb 27 14:21:29 2018 -0800
+++ b/mercurial/wireprotoserver.py	Tue Feb 27 14:26:00 2018 -0800
@@ -33,11 +33,8 @@
 HGTYPE2 = 'application/mercurial-0.2'
 HGERRTYPE = 'application/hg-error'
 
-# Names of the SSH protocol implementations.
-SSHV1 = 'ssh-v1'
-# This is advertised over the wire. Incremental the counter at the end
-# to reflect BC breakages.
-SSHV2 = 'exp-ssh-v2-0001'
+SSHV1 = wireprototypes.SSHV1
+SSHV2 = wireprototypes.SSHV2
 
 def decodevaluefromheaders(req, headerprefix):
     """Decode a long value from multiple HTTP request headers.
@@ -324,7 +321,7 @@
 
     @property
     def name(self):
-        return SSHV1
+        return wireprototypes.SSHV1
 
     def getargs(self, args):
         data = {}
@@ -492,7 +489,7 @@
             # We should never transition into this state if we've switched
             # protocols.
             assert not protoswitched
-            assert proto.name == SSHV1
+            assert proto.name == wireprototypes.SSHV1
 
             # Expected: upgrade <token> <capabilities>
             # If we get something else, the request is malformed. It could be
--- a/mercurial/wireprototypes.py	Tue Feb 27 14:21:29 2018 -0800
+++ b/mercurial/wireprototypes.py	Tue Feb 27 14:26:00 2018 -0800
@@ -7,6 +7,12 @@
 
 import abc
 
+# Names of the SSH protocol implementations.
+SSHV1 = 'ssh-v1'
+# This is advertised over the wire. Incremental the counter at the end
+# to reflect BC breakages.
+SSHV2 = 'exp-ssh-v2-0001'
+
 class bytesresponse(object):
     """A wire protocol response consisting of raw bytes."""
     def __init__(self, data):