Patchwork D2482: wireprotoserver: move SSHV1 and SSHV2 constants to wireprototypes

login
register
mail settings
Submitter phabricator
Date March 1, 2018, 9:56 p.m.
Message ID <bcb368ecee7c638e234a42ecbb4ecce7@localhost.localdomain>
Download mbox | patch
Permalink /patch/28606/
State Not Applicable
Headers show

Comments

phabricator - March 1, 2018, 9:56 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG049c038f56f8: wireprotoserver: move SSHV1 and SSHV2 constants to wireprototypes (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2482?vs=6181&id=6291

REVISION DETAIL
  https://phab.mercurial-scm.org/D2482

AFFECTED FILES
  mercurial/sshpeer.py
  mercurial/wireprotoserver.py
  mercurial/wireprototypes.py

CHANGE DETAILS




To: indygreg, #hg-reviewers, durin42
Cc: mercurial-devel

Patch

diff --git a/mercurial/wireprototypes.py b/mercurial/wireprototypes.py
--- a/mercurial/wireprototypes.py
+++ b/mercurial/wireprototypes.py
@@ -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):
diff --git a/mercurial/wireprotoserver.py b/mercurial/wireprotoserver.py
--- a/mercurial/wireprotoserver.py
+++ b/mercurial/wireprotoserver.py
@@ -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
diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
--- a/mercurial/sshpeer.py
+++ b/mercurial/sshpeer.py
@@ -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: