changeset 36397:a34d5ef53c2e

sshpeer: move logic for sending a request into a new function The **args being used to pass arbitrary command arguments is limiting because it makes it harder to control behavior of the function. We factor most of _callstream() into a new function that doesn't use **args. Differential Revision: https://phab.mercurial-scm.org/D2379
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 21 Feb 2018 08:33:50 -0800
parents 7f8f74531b0b
children 043e77f3be09
files mercurial/sshpeer.py
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/sshpeer.py	Mon Feb 19 15:57:28 2018 -0800
+++ b/mercurial/sshpeer.py	Wed Feb 21 08:33:50 2018 -0800
@@ -410,8 +410,7 @@
             work += chunk
         yield wireproto.unescapearg(work)
 
-    def _callstream(self, cmd, **args):
-        args = pycompat.byteskwargs(args)
+    def _sendrequest(self, cmd, args):
         if (self.ui.debugflag
             and self.ui.configbool('devel', 'debug.peer-request')):
             dbg = self.ui.debug
@@ -447,11 +446,17 @@
 
         return self._pipei
 
+    def _callstream(self, cmd, **args):
+        args = pycompat.byteskwargs(args)
+        return self._sendrequest(cmd, args)
+
     def _callcompressable(self, cmd, **args):
-        return self._callstream(cmd, **args)
+        args = pycompat.byteskwargs(args)
+        return self._sendrequest(cmd, args)
 
     def _call(self, cmd, **args):
-        self._callstream(cmd, **args)
+        args = pycompat.byteskwargs(args)
+        self._sendrequest(cmd, args)
         return self._readframed()
 
     def _callpush(self, cmd, fp, **args):