comparison mercurial/wireprotoserver.py @ 36069:957e773614d0

wireprotoserver: rename _client to client (API) This method is called in wireproto.py. It should be part of the public API/interface. .. api:: The ``_client()`` method of the wire protocol handler interface has been renamed to ``client()``. Differential Revision: https://phab.mercurial-scm.org/D2084
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 07 Feb 2018 20:24:22 -0800
parents 56fe8a3b2d52
children 90ca4986616c
comparison
equal deleted inserted replaced
36068:56fe8a3b2d52 36069:957e773614d0
85 The intent of this context manager is to capture stdio output 85 The intent of this context manager is to capture stdio output
86 so it may be sent in the response. Some transports support streaming 86 so it may be sent in the response. Some transports support streaming
87 stdio to the client in real time. For these transports, stdio output 87 stdio to the client in real time. For these transports, stdio output
88 won't be captured. 88 won't be captured.
89 """ 89 """
90
91 @abc.abstractmethod
92 def client(self):
93 """Returns a string representation of this client (as bytes)."""
90 94
91 def decodevaluefromheaders(req, headerprefix): 95 def decodevaluefromheaders(req, headerprefix):
92 """Decode a long value from multiple HTTP request headers. 96 """Decode a long value from multiple HTTP request headers.
93 97
94 Returns the value as a bytes, not a str. 98 Returns the value as a bytes, not a str.
162 yield out 166 yield out
163 finally: 167 finally:
164 self._ui.fout = oldout 168 self._ui.fout = oldout
165 self._ui.ferr = olderr 169 self._ui.ferr = olderr
166 170
167 def _client(self): 171 def client(self):
168 return 'remote:%s:%s:%s' % ( 172 return 'remote:%s:%s:%s' % (
169 self._req.env.get('wsgi.url_scheme') or 'http', 173 self._req.env.get('wsgi.url_scheme') or 'http',
170 urlreq.quote(self._req.env.get('REMOTE_HOST', '')), 174 urlreq.quote(self._req.env.get('REMOTE_HOST', '')),
171 urlreq.quote(self._req.env.get('REMOTE_USER', ''))) 175 urlreq.quote(self._req.env.get('REMOTE_USER', '')))
172 176
397 401
398 @contextlib.contextmanager 402 @contextlib.contextmanager
399 def mayberedirectstdio(self): 403 def mayberedirectstdio(self):
400 yield None 404 yield None
401 405
402 def _client(self): 406 def client(self):
403 client = encoding.environ.get('SSH_CLIENT', '').split(' ', 1)[0] 407 client = encoding.environ.get('SSH_CLIENT', '').split(' ', 1)[0]
404 return 'remote:ssh:' + client 408 return 'remote:ssh:' + client
405 409
406 class sshserver(object): 410 class sshserver(object):
407 def __init__(self, ui, repo): 411 def __init__(self, ui, repo):