Patchwork D1989: wireprotoserver: make response handling attributes private

login
register
mail settings
Submitter phabricator
Date Feb. 1, 2018, 11:12 p.m.
Message ID <differential-rev-PHID-DREV-u7gnevnnnm6qhrggbm3s-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/27180/
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
  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.

REPOSITORY
  rHG Mercurial

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

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
@@ -283,34 +283,34 @@ 
         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))
             count = int(self._fin.readline())
 
     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):