Patchwork D1991: wireprotoserver: make name part of protocol interface

login
register
mail settings
Submitter phabricator
Date Feb. 1, 2018, 11:12 p.m.
Message ID <differential-rev-PHID-DREV-mc666gecpuexhb7fbuge-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/27182/
State Superseded
Headers show

Comments

phabricator - Feb. 1, 2018, 11:12 p.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is a required part of the interface. Abstract properties must
  be defined at type creation time. So we make name a @property.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/wireprotoserver.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/wireprotoserver.py b/mercurial/wireprotoserver.py
--- a/mercurial/wireprotoserver.py
+++ b/mercurial/wireprotoserver.py
@@ -40,6 +40,13 @@ 
 
     __metaclass__ = abc.ABCMeta
 
+    @abc.abstractproperty
+    def name(self):
+        """The name of the protocol implementation.
+
+        Used for uniquely identifying the transport type.
+        """
+
     @abc.abstractmethod
     def getargs(self, args):
         """return the value for arguments in <args>
@@ -95,7 +102,10 @@ 
     def __init__(self, req, ui):
         self._req = req
         self._ui = ui
-        self.name = 'http'
+
+    @property
+    def name(self):
+        return 'http'
 
     def getargs(self, args):
         knownargs = self._args()
@@ -255,15 +265,18 @@ 
         self._repo = repo
         self._fin = ui.fin
         self._fout = ui.fout
-        self.name = 'ssh'
 
         hook.redirect(True)
         ui.fout = repo.ui.fout = ui.ferr
 
         # Prevent insertion/deletion of CRs
         util.setbinary(self._fin)
         util.setbinary(self._fout)
 
+    @property
+    def name(self):
+        return 'ssh'
+
     def getargs(self, args):
         data = {}
         keys = args.split()