changeset 35871:49ea1ba15ffd

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
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 31 Jan 2018 11:26:03 -0800
parents f1efc0caeab7
children 68dc621fa06c
files mercurial/wireprotoserver.py
diffstat 1 files changed, 18 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- 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):