D2378: sshpeer: rename _recv and _send to _readframed and _writeframed

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Wed Feb 21 17:08:11 EST 2018


indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Because it is reading and writing a chunk of data with a well-defined
  size. "recv" and "send" make it sound like things are a direct proxy to
  the underlying pipe, which they aren't.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/sshpeer.py

CHANGE DETAILS

diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
--- a/mercurial/sshpeer.py
+++ b/mercurial/sshpeer.py
@@ -452,28 +452,28 @@
 
     def _call(self, cmd, **args):
         self._callstream(cmd, **args)
-        return self._recv()
+        return self._readframed()
 
     def _callpush(self, cmd, fp, **args):
         r = self._call(cmd, **args)
         if r:
             return '', r
         for d in iter(lambda: fp.read(4096), ''):
-            self._send(d)
-        self._send("", flush=True)
-        r = self._recv()
+            self._writeframed(d)
+        self._writeframed("", flush=True)
+        r = self._readframed()
         if r:
             return '', r
-        return self._recv(), ''
+        return self._readframed(), ''
 
     def _calltwowaystream(self, cmd, fp, **args):
         r = self._call(cmd, **args)
         if r:
             # XXX needs to be made better
             raise error.Abort(_('unexpected remote reply: %s') % r)
         for d in iter(lambda: fp.read(4096), ''):
-            self._send(d)
-        self._send("", flush=True)
+            self._writeframed(d)
+        self._writeframed("", flush=True)
         return self._pipei
 
     def _getamount(self):
@@ -488,10 +488,10 @@
         except ValueError:
             self._abort(error.ResponseError(_("unexpected response:"), l))
 
-    def _recv(self):
+    def _readframed(self):
         return self._pipei.read(self._getamount())
 
-    def _send(self, data, flush=False):
+    def _writeframed(self, data, flush=False):
         self._pipeo.write("%d\n" % len(data))
         if data:
             self._pipeo.write(data)



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


More information about the Mercurial-devel mailing list