wireprotoserver: make response handling attributes private
authorGregory Szorc <gregory.szorc@gmail.com>
Wed, 31 Jan 2018 11:26:03 -0800
changeset 35911 49ea1ba15ffd
parent 35910 f1efc0caeab7
child 35912 68dc621fa06c
wireprotoserver: make response handling attributes private The send* methods are specific to sshserver and aren't part of the common protocol interface. So rename them accordingly. The handlers dict is also specific to sshserver and is related to these methods. So give it the same treatment. Differential Revision: https://phab.mercurial-scm.org/D1989
mercurial/wireprotoserver.py
--- a/mercurial/wireprotoserver.py	Wed Jan 31 11:24:44 2018 -0800
+++ b/mercurial/wireprotoserver.py	Wed Jan 31 11:26:03 2018 -0800
@@ -283,7 +283,7 @@
         return [data[k] for k in keys]
 
     def getfile(self, fpout):
-        self.sendresponse('')
+        self._sendresponse('')
         count = int(self._fin.readline())
         while count:
             fpout.write(self._fin.read(count))
@@ -292,25 +292,25 @@
     def redirect(self):
         pass
 
-    def sendresponse(self, v):
+    def _sendresponse(self, v):
         self._fout.write("%d\n" % len(v))
         self._fout.write(v)
         self._fout.flush()
 
-    def sendstream(self, source):
+    def _sendstream(self, source):
         write = self._fout.write
         for chunk in source.gen:
             write(chunk)
         self._fout.flush()
 
-    def sendpushresponse(self, rsp):
-        self.sendresponse('')
-        self.sendresponse(str(rsp.res))
+    def _sendpushresponse(self, rsp):
+        self._sendresponse('')
+        self._sendresponse(str(rsp.res))
 
-    def sendpusherror(self, rsp):
-        self.sendresponse(rsp.res)
+    def _sendpusherror(self, rsp):
+        self._sendresponse(rsp.res)
 
-    def sendooberror(self, rsp):
+    def _sendooberror(self, rsp):
         self._ui.ferr.write('%s\n-\n' % rsp.message)
         self._ui.ferr.flush()
         self._fout.write('\n')
@@ -321,22 +321,22 @@
             pass
         sys.exit(0)
 
-    handlers = {
-        str: sendresponse,
-        wireproto.streamres: sendstream,
-        wireproto.streamres_legacy: sendstream,
-        wireproto.pushres: sendpushresponse,
-        wireproto.pusherr: sendpusherror,
-        wireproto.ooberror: sendooberror,
+    _handlers = {
+        str: _sendresponse,
+        wireproto.streamres: _sendstream,
+        wireproto.streamres_legacy: _sendstream,
+        wireproto.pushres: _sendpushresponse,
+        wireproto.pusherr: _sendpusherror,
+        wireproto.ooberror: _sendooberror,
     }
 
     def serve_one(self):
         cmd = self._fin.readline()[:-1]
         if cmd and cmd in wireproto.commands:
             rsp = wireproto.dispatch(self._repo, self, cmd)
-            self.handlers[rsp.__class__](self, rsp)
+            self._handlers[rsp.__class__](self, rsp)
         elif cmd:
-            self.sendresponse("")
+            self._sendresponse("")
         return cmd != ''
 
     def _client(self):