Patchwork [1,of,4] sshpeer: rename 'size' to 'data' in doublepipe

login
register
mail settings
Submitter Pierre-Yves David
Date June 5, 2015, 6:19 p.m.
Message ID <f3b870f69c3a131e6bf4.1433528353@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/9521/
State Accepted
Headers show

Comments

Pierre-Yves David - June 5, 2015, 6:19 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1432161647 18000
#      Wed May 20 17:40:47 2015 -0500
# Node ID f3b870f69c3a131e6bf4f54fb58dcb4ac91b290e
# Parent  51e7acc34b0ab0e540dffdb22127914f2353d5e2
sshpeer: rename 'size' to 'data' in doublepipe

We are about to add 'write' support, the argument will be either an int or a
string.

Patch

diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
--- a/mercurial/sshpeer.py
+++ b/mercurial/sshpeer.py
@@ -79,26 +79,27 @@  class doublepipe(object):
         return self._call('read', size)
 
     def readline(self):
         return self._call('readline')
 
-    def _call(self, methname, size=None):
+    def _call(self, methname, data=None):
         """call <methname> on "main", forward output of "side" while blocking
         """
-        if size == 0 or self._main.closed:
+        # data can be '' or 0
+        if (data is not None and not data) or self._main.closed:
             _forwardoutput(self._ui, self._side)
             return ''
         while True:
             mainready, sideready = self._wait()
             if sideready:
                 _forwardoutput(self._ui, self._side)
             if mainready:
                 meth = getattr(self._main, methname)
-                if size is None:
+                if data is None:
                     return meth()
                 else:
-                    return meth(size)
+                    return meth(data)
 
     def close(self):
         return self._main.close()
 
 class sshpeer(wireproto.wirepeer):