diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py --- a/mercurial/httppeer.py +++ b/mercurial/httppeer.py @@ -744,14 +744,12 @@ while handler.readdata(resp): pass -# TODO implement interface for version 2 peers -@interfaceutil.implementer(repository.ipeerconnection, - repository.ipeercapabilities, - repository.ipeerrequests) +@interfaceutil.implementer(repository.ipeerv2) class httpv2peer(object): def __init__(self, ui, repourl, apipath, opener, requestbuilder, apidescriptor): self.ui = ui + self.apidescriptor = apidescriptor if repourl.endswith('/'): repourl = repourl[:-1] @@ -761,7 +759,6 @@ self._apiurl = '%s/%s' % (repourl, apipath) self._opener = opener self._requestbuilder = requestbuilder - self._descriptor = apidescriptor self._redirect = wireprotov2peer.supportedredirects(ui, apidescriptor) @@ -806,7 +803,7 @@ # Alias command-* to presence of command of that name. if name.startswith('command-'): - return name[len('command-'):] in self._descriptor['commands'] + return name[len('command-'):] in self.apidescriptor['commands'] return False @@ -826,7 +823,7 @@ def commandexecutor(self): return httpv2executor(self.ui, self._opener, self._requestbuilder, - self._apiurl, self._descriptor, self._redirect) + self._apiurl, self.apidescriptor, self._redirect) # Registry of API service names to metadata about peers that handle it. # diff --git a/mercurial/repository.py b/mercurial/repository.py --- a/mercurial/repository.py +++ b/mercurial/repository.py @@ -312,6 +312,12 @@ All peer instances must conform to this interface. """ +class ipeerv2(ipeerconnection, ipeercapabilities, ipeerrequests): + """Unified peer interface for wire protocol version 2 peers.""" + + apidescriptor = interfaceutil.Attribute( + """Data structure holding description of server API.""") + @interfaceutil.implementer(ipeerbase) class peer(object): """Base class for peer repositories.""" diff --git a/tests/test-check-interfaces.py b/tests/test-check-interfaces.py --- a/tests/test-check-interfaces.py +++ b/tests/test-check-interfaces.py @@ -106,10 +106,7 @@ ziverify.verifyClass(repository.ipeerbase, httppeer.httppeer) checkzobject(httppeer.httppeer(None, None, None, dummyopener(), None, None)) - ziverify.verifyClass(repository.ipeerconnection, - httppeer.httpv2peer) - ziverify.verifyClass(repository.ipeercapabilities, - httppeer.httpv2peer) + ziverify.verifyClass(repository.ipeerv2, httppeer.httpv2peer) checkzobject(httppeer.httpv2peer(None, b'', b'', None, None, None)) ziverify.verifyClass(repository.ipeerbase,