Patchwork D336: sshpeer: use peer interface

login
register
mail settings
Submitter phabricator
Date Aug. 15, 2017, 5:51 p.m.
Message ID <216b8f6f4aa2718f3654f3b04556d6d1@localhost.localdomain>
Download mbox | patch
Permalink /patch/23029/
State Not Applicable
Headers show

Comments

phabricator - Aug. 15, 2017, 5:51 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG1f8460b55986: sshpeer: use peer interface (authored by indygreg).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D336?vs=761&id=935

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

AFFECTED FILES
  mercurial/sshpeer.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
--- a/mercurial/sshpeer.py
+++ b/mercurial/sshpeer.py
@@ -13,6 +13,7 @@ 
 from . import (
     error,
     pycompat,
+    repository,
     util,
     wireproto,
 )
@@ -114,10 +115,10 @@ 
     def flush(self):
         return self._main.flush()
 
-class sshpeer(wireproto.wirepeer):
+class sshpeer(wireproto.wirepeer, repository.legacypeer):
     def __init__(self, ui, path, create=False):
         self._url = path
-        self.ui = ui
+        self._ui = ui
         self._pipeo = self._pipei = self._pipee = None
 
         u = util.url(path, parsequery=False, parsefragment=False)
@@ -150,9 +151,39 @@ 
 
         self._validaterepo(sshcmd, args, remotecmd)
 
+        # TODO remove this alias once peerrepository inheritance is removed.
+        self._capabilities = self.capabilities
+
+    # Begin of _basepeer interface.
+
+    @util.propertycache
+    def ui(self):
+        return self._ui
+
     def url(self):
         return self._url
 
+    def local(self):
+        return None
+
+    def peer(self):
+        return self
+
+    def canpush(self):
+        return True
+
+    def close(self):
+        pass
+
+    # End of _basepeer interface.
+
+    # Begin of _basewirecommands interface.
+
+    def capabilities(self):
+        return self._caps
+
+    # End of _basewirecommands interface.
+
     def _validaterepo(self, sshcmd, args, remotecmd):
         # cleanup up previous run
         self._cleanup()
@@ -200,9 +231,6 @@ 
                 self._caps.update(l[:-1].split(":")[1].split())
                 break
 
-    def _capabilities(self):
-        return self._caps
-
     def _readerr(self):
         _forwardoutput(self.ui, self._pipee)