##// END OF EJS Templates
httppeer: expose API descriptor on httpv2peer...
Gregory Szorc -
r40207:dac438b7 default
parent child Browse files
Show More
@@ -744,14 +744,12 b' class httpv2executor(object):'
744 while handler.readdata(resp):
744 while handler.readdata(resp):
745 pass
745 pass
746
746
747 # TODO implement interface for version 2 peers
747 @interfaceutil.implementer(repository.ipeerv2)
748 @interfaceutil.implementer(repository.ipeerconnection,
749 repository.ipeercapabilities,
750 repository.ipeerrequests)
751 class httpv2peer(object):
748 class httpv2peer(object):
752 def __init__(self, ui, repourl, apipath, opener, requestbuilder,
749 def __init__(self, ui, repourl, apipath, opener, requestbuilder,
753 apidescriptor):
750 apidescriptor):
754 self.ui = ui
751 self.ui = ui
752 self.apidescriptor = apidescriptor
755
753
756 if repourl.endswith('/'):
754 if repourl.endswith('/'):
757 repourl = repourl[:-1]
755 repourl = repourl[:-1]
@@ -761,7 +759,6 b' class httpv2peer(object):'
761 self._apiurl = '%s/%s' % (repourl, apipath)
759 self._apiurl = '%s/%s' % (repourl, apipath)
762 self._opener = opener
760 self._opener = opener
763 self._requestbuilder = requestbuilder
761 self._requestbuilder = requestbuilder
764 self._descriptor = apidescriptor
765
762
766 self._redirect = wireprotov2peer.supportedredirects(ui, apidescriptor)
763 self._redirect = wireprotov2peer.supportedredirects(ui, apidescriptor)
767
764
@@ -806,7 +803,7 b' class httpv2peer(object):'
806
803
807 # Alias command-* to presence of command of that name.
804 # Alias command-* to presence of command of that name.
808 if name.startswith('command-'):
805 if name.startswith('command-'):
809 return name[len('command-'):] in self._descriptor['commands']
806 return name[len('command-'):] in self.apidescriptor['commands']
810
807
811 return False
808 return False
812
809
@@ -826,7 +823,7 b' class httpv2peer(object):'
826
823
827 def commandexecutor(self):
824 def commandexecutor(self):
828 return httpv2executor(self.ui, self._opener, self._requestbuilder,
825 return httpv2executor(self.ui, self._opener, self._requestbuilder,
829 self._apiurl, self._descriptor, self._redirect)
826 self._apiurl, self.apidescriptor, self._redirect)
830
827
831 # Registry of API service names to metadata about peers that handle it.
828 # Registry of API service names to metadata about peers that handle it.
832 #
829 #
@@ -312,6 +312,12 b' class ipeerbase(ipeerconnection, ipeerca'
312 All peer instances must conform to this interface.
312 All peer instances must conform to this interface.
313 """
313 """
314
314
315 class ipeerv2(ipeerconnection, ipeercapabilities, ipeerrequests):
316 """Unified peer interface for wire protocol version 2 peers."""
317
318 apidescriptor = interfaceutil.Attribute(
319 """Data structure holding description of server API.""")
320
315 @interfaceutil.implementer(ipeerbase)
321 @interfaceutil.implementer(ipeerbase)
316 class peer(object):
322 class peer(object):
317 """Base class for peer repositories."""
323 """Base class for peer repositories."""
@@ -106,10 +106,7 b' def main():'
106 ziverify.verifyClass(repository.ipeerbase, httppeer.httppeer)
106 ziverify.verifyClass(repository.ipeerbase, httppeer.httppeer)
107 checkzobject(httppeer.httppeer(None, None, None, dummyopener(), None, None))
107 checkzobject(httppeer.httppeer(None, None, None, dummyopener(), None, None))
108
108
109 ziverify.verifyClass(repository.ipeerconnection,
109 ziverify.verifyClass(repository.ipeerv2, httppeer.httpv2peer)
110 httppeer.httpv2peer)
111 ziverify.verifyClass(repository.ipeercapabilities,
112 httppeer.httpv2peer)
113 checkzobject(httppeer.httpv2peer(None, b'', b'', None, None, None))
110 checkzobject(httppeer.httpv2peer(None, b'', b'', None, None, None))
114
111
115 ziverify.verifyClass(repository.ipeerbase,
112 ziverify.verifyClass(repository.ipeerbase,
General Comments 0
You need to be logged in to leave comments. Login now