changeset 35913:29759c46aa1a

wireprotoserver: make name part of protocol interface This is a required part of the interface. Abstract properties must be defined at type creation time. So we make name a @property. Differential Revision: https://phab.mercurial-scm.org/D1991
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 31 Jan 2018 11:32:21 -0800
parents 68dc621fa06c
children 1bee7762fd46
files mercurial/wireprotoserver.py
diffstat 1 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/wireprotoserver.py	Wed Jan 31 11:30:16 2018 -0800
+++ b/mercurial/wireprotoserver.py	Wed Jan 31 11:32:21 2018 -0800
@@ -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,7 +265,6 @@
         self._repo = repo
         self._fin = ui.fin
         self._fout = ui.fout
-        self.name = 'ssh'
 
         hook.redirect(True)
         ui.fout = repo.ui.fout = ui.ferr
@@ -264,6 +273,10 @@
         util.setbinary(self._fin)
         util.setbinary(self._fout)
 
+    @property
+    def name(self):
+        return 'ssh'
+
     def getargs(self, args):
         data = {}
         keys = args.split()