equal
deleted
inserted
replaced
36 SSHV1 = 'ssh-v1' |
36 SSHV1 = 'ssh-v1' |
37 # This is advertised over the wire. Incremental the counter at the end |
37 # This is advertised over the wire. Incremental the counter at the end |
38 # to reflect BC breakages. |
38 # to reflect BC breakages. |
39 SSHV2 = 'exp-ssh-v2-0001' |
39 SSHV2 = 'exp-ssh-v2-0001' |
40 |
40 |
41 class abstractserverproto(object): |
41 class baseprotocolhandler(object): |
42 """abstract class that summarizes the protocol API |
42 """Abstract base class for wire protocol handlers. |
43 |
43 |
44 Used as reference and documentation. |
44 A wire protocol handler serves as an interface between protocol command |
|
45 handlers and the wire protocol transport layer. Protocol handlers provide |
|
46 methods to read command arguments, redirect stdio for the duration of |
|
47 the request, handle response types, etc. |
45 """ |
48 """ |
46 |
49 |
47 __metaclass__ = abc.ABCMeta |
50 __metaclass__ = abc.ABCMeta |
48 |
51 |
49 @abc.abstractproperty |
52 @abc.abstractproperty |
102 chunks.append(pycompat.bytesurl(v)) |
105 chunks.append(pycompat.bytesurl(v)) |
103 i += 1 |
106 i += 1 |
104 |
107 |
105 return ''.join(chunks) |
108 return ''.join(chunks) |
106 |
109 |
107 class webproto(abstractserverproto): |
110 class webproto(baseprotocolhandler): |
108 def __init__(self, req, ui): |
111 def __init__(self, req, ui): |
109 self._req = req |
112 self._req = req |
110 self._ui = ui |
113 self._ui = ui |
111 |
114 |
112 @property |
115 @property |
331 # "unbundle." That assumption is not always valid. |
334 # "unbundle." That assumption is not always valid. |
332 req.respond(e, HGTYPE, body='0\n%s\n' % e) |
335 req.respond(e, HGTYPE, body='0\n%s\n' % e) |
333 |
336 |
334 return '' |
337 return '' |
335 |
338 |
336 class sshserver(abstractserverproto): |
339 class sshserver(baseprotocolhandler): |
337 def __init__(self, ui, repo): |
340 def __init__(self, ui, repo): |
338 self._ui = ui |
341 self._ui = ui |
339 self._repo = repo |
342 self._repo = repo |
340 self._fin = ui.fin |
343 self._fin = ui.fin |
341 self._fout = ui.fout |
344 self._fout = ui.fout |