comparison mercurial/httppeer.py @ 37320:39f7d4ee8bcd

repository: port peer interfaces to zope.interface zope.interface is superior. Let's switch to it. Unlike abc, which defines interfaces through a base class, zope.interface uses different types for interfaces and for implementations. So, we had to invent some new types to hold the interfaces in order to separate the interface from its default implementation. The names here could probably be better. I've been wanting to overhaul the peer interface for a while. And wire protocol version 2 will force that work. So anticipate a refactoring of these interfaces in later commits. With this commit, we no longer test abc interfaces in test-check-interfaces.py, so code for that has been removed. Differential Revision: https://phab.mercurial-scm.org/D3068 # no-check-commit because of stream_out()
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 30 Mar 2018 18:53:17 -0700
parents 8e89c2bec1f7
children e826fe7a08c7
comparison
equal deleted inserted replaced
37319:36d17f37db91 37320:39f7d4ee8bcd
182 if self._ui.configbool('devel', 'debug.peer-request'): 182 if self._ui.configbool('devel', 'debug.peer-request'):
183 dbg(line % ' finished in %.4f seconds (%s)' 183 dbg(line % ' finished in %.4f seconds (%s)'
184 % (util.timer() - start, ret.code)) 184 % (util.timer() - start, ret.code))
185 return ret 185 return ret
186 186
187 # Begin of _basepeer interface. 187 # Begin of ipeerconnection interface.
188 188
189 @util.propertycache 189 @util.propertycache
190 def ui(self): 190 def ui(self):
191 return self._ui 191 return self._ui
192 192
203 return True 203 return True
204 204
205 def close(self): 205 def close(self):
206 pass 206 pass
207 207
208 # End of _basepeer interface. 208 # End of ipeerconnection interface.
209 209
210 # Begin of _basewirepeer interface. 210 # Begin of ipeercommands interface.
211 211
212 def capabilities(self): 212 def capabilities(self):
213 # self._fetchcaps() should have been called as part of peer 213 # self._fetchcaps() should have been called as part of peer
214 # handshake. So self._caps should always be set. 214 # handshake. So self._caps should always be set.
215 assert self._caps is not None 215 assert self._caps is not None
216 return self._caps 216 return self._caps
217 217
218 # End of _basewirepeer interface. 218 # End of ipeercommands interface.
219 219
220 # look up capabilities only when needed 220 # look up capabilities only when needed
221 221
222 def _fetchcaps(self): 222 def _fetchcaps(self):
223 self._caps = set(self._call('capabilities').split()) 223 self._caps = set(self._call('capabilities').split())