D2581: sshpeer: don't read(0)

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Sat Mar 3 10:22:35 EST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG70415568ea65: sshpeer: don't read(0) (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2581?vs=6425&id=6429

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

AFFECTED FILES
  mercurial/sshpeer.py
  tests/test-ssh-proto-unbundle.t

CHANGE DETAILS

diff --git a/tests/test-ssh-proto-unbundle.t b/tests/test-ssh-proto-unbundle.t
--- a/tests/test-ssh-proto-unbundle.t
+++ b/tests/test-ssh-proto-unbundle.t
@@ -88,7 +88,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 0
@@ -139,7 +138,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 0
@@ -257,7 +255,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 0
@@ -314,7 +311,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 0
@@ -385,7 +381,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 0
@@ -443,7 +438,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 0
@@ -515,7 +509,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 0
@@ -572,7 +565,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 0
@@ -643,7 +635,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 0
@@ -701,7 +692,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 0
@@ -773,7 +763,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 0
@@ -833,7 +822,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 0
@@ -907,7 +895,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 0
@@ -964,7 +951,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 0
@@ -1035,7 +1021,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 0
@@ -1095,7 +1080,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 0
@@ -1169,7 +1153,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 0
@@ -1229,7 +1212,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 0
@@ -1309,7 +1291,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 0
@@ -1367,7 +1348,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 0
@@ -1440,7 +1420,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 0
@@ -1498,7 +1477,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 0
@@ -1573,7 +1551,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 0
@@ -1633,7 +1610,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 0
@@ -1716,7 +1692,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 0
@@ -1780,7 +1755,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 0
@@ -1858,7 +1832,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 1
@@ -1911,7 +1884,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 1
@@ -1990,7 +1962,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 1
@@ -2047,7 +2018,6 @@
   i> flush() -> None
   o> readline() -> 2:
   o>     0\n
-  o> read(0) -> 0: 
   o> readline() -> 2:
   o>     1\n
   o> read(1) -> 1: 1
diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
--- a/mercurial/sshpeer.py
+++ b/mercurial/sshpeer.py
@@ -523,7 +523,11 @@
             self._abort(error.ResponseError(_("unexpected response:"), l))
 
     def _readframed(self):
-        return self._pipei.read(self._getamount())
+        size = self._getamount()
+        if not size:
+            return b''
+
+        return self._pipei.read(size)
 
     def _writeframed(self, data, flush=False):
         self._pipeo.write("%d\n" % len(data))



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


More information about the Mercurial-devel mailing list