Patchwork D3254: httppeer: implement ipeerconnection

login
register
mail settings
Submitter phabricator
Date April 12, 2018, 10:23 p.m.
Message ID <85bee112e306079cc94195cf4cfa77b0@localhost.localdomain>
Download mbox | patch
Permalink /patch/30837/
State Not Applicable
Headers show

Comments

phabricator - April 12, 2018, 10:23 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG01bfe5ad0c53: httppeer: implement ipeerconnection (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3254?vs=8020&id=8095

REVISION DETAIL
  https://phab.mercurial-scm.org/D3254

AFFECTED FILES
  mercurial/httppeer.py
  tests/test-check-interfaces.py

CHANGE DETAILS




To: indygreg, #hg-reviewers, durin42
Cc: mercurial-devel

Patch

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
@@ -92,6 +92,10 @@ 
                          httppeer.httppeer)
     checkzobject(httppeer.httppeer(None, None, None, dummyopener(), None, None))
 
+    ziverify.verifyClass(repository.ipeerconnection,
+                         httppeer.httpv2peer)
+    checkzobject(httppeer.httpv2peer(None, '', None, None, None, None))
+
     ziverify.verifyClass(repository.ipeerbase,
                          localrepo.localpeer)
     checkzobject(localrepo.localpeer(dummyrepo()))
diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py
--- a/mercurial/httppeer.py
+++ b/mercurial/httppeer.py
@@ -19,11 +19,15 @@ 
 from .thirdparty import (
     cbor,
 )
+from .thirdparty.zope import (
+    interface as zi,
+)
 from . import (
     bundle2,
     error,
     httpconnection,
     pycompat,
+    repository,
     statichttprepo,
     url as urlmod,
     util,
@@ -513,23 +517,41 @@ 
         raise exception
 
 # TODO implement interface for version 2 peers
+@zi.implementer(repository.ipeerconnection)
 class httpv2peer(object):
     def __init__(self, ui, repourl, apipath, opener, requestbuilder,
                  apidescriptor):
         self.ui = ui
 
         if repourl.endswith('/'):
             repourl = repourl[:-1]
 
-        self.url = repourl
+        self._url = repourl
         self._apipath = apipath
         self._opener = opener
         self._requestbuilder = requestbuilder
         self._descriptor = apidescriptor
 
+    # Start of ipeerconnection.
+
+    def url(self):
+        return self._url
+
+    def local(self):
+        return None
+
+    def peer(self):
+        return self
+
+    def canpush(self):
+        # TODO change once implemented.
+        return False
+
     def close(self):
         pass
 
+    # End of ipeerconnection.
+
     # TODO require to be part of a batched primitive, use futures.
     def _call(self, name, **args):
         """Call a wire protocol command with arguments."""
@@ -554,7 +576,7 @@ 
             'pull': 'ro',
         }[permission]
 
-        url = '%s/%s/%s/%s' % (self.url, self._apipath, permission, name)
+        url = '%s/%s/%s/%s' % (self._url, self._apipath, permission, name)
 
         # TODO this should be part of a generic peer for the frame-based
         # protocol.