indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is similar to what we did to sshpeer. Quirks and all.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/httppeer.py

CHANGE DETAILS

diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py
--- a/mercurial/httppeer.py
+++ b/mercurial/httppeer.py
@@ -21,6 +21,7 @@
     error,
     httpconnection,
     pycompat,
+    repository,
     statichttprepo,
     url,
     util,
@@ -86,7 +87,7 @@
 
     resp.__class__ = readerproxy
 
-class httppeer(wireproto.wirepeer):
+class httppeer(wireproto.wirepeer, repository.legacypeer):
     def __init__(self, ui, path):
         self._path = path
         self._caps = None
@@ -100,28 +101,48 @@
         # urllib cannot handle URLs with embedded user or passwd
         self._url, authinfo = u.authinfo()
 
-        self.ui = ui
-        self.ui.debug('using %s\n' % self._url)
+        self._ui = ui
+        ui.debug('using %s\n' % self._url)
 
         self._urlopener = url.opener(ui, authinfo)
         self._requestbuilder = urlreq.request
 
+        # TODO remove once peerrepository isn't in inheritance.
+        self._capabilities = self.capabilities
+
     def __del__(self):
         urlopener = getattr(self, '_urlopener', None)
         if urlopener:
             for h in urlopener.handlers:
                 h.close()
                 getattr(h, "close_all", lambda : None)()
 
+    # Begin of _basepeer interface.
+
+    @util.propertycache
+    def ui(self):
+        return self._ui
+
     def url(self):
         return self._path
 
-    # look up capabilities only when needed
+    def local(self):
+        return None
+
+    def peer(self):
+        return self
+
+    def canpush(self):
+        return True
 
-    def _fetchcaps(self):
-        self._caps = set(self._call('capabilities').split())
+    def close(self):
+        pass
 
-    def _capabilities(self):
+    # End of _basepeer interface.
+
+    # Begin of _basewirepeer interface.
+
+    def capabilities(self):
         if self._caps is None:
             try:
                 self._fetchcaps()
@@ -131,6 +152,13 @@
                           (' '.join(self._caps or ['none'])))
         return self._caps
 
+    # End of _basewirepeer interface.
+
+    # look up capabilities only when needed
+
+    def _fetchcaps(self):
+        self._caps = set(self._call('capabilities').split())
+
     def _callstream(self, cmd, _compressible=False, **args):
         if cmd == 'pushkey':
             args['data'] = ''



To: indygreg, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to