D2571: sshpeer: don't read from stderr when that behavior is disabled

2018-03-02 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG1151c731686e: sshpeer: dont read from stderr when 
that behavior is disabled (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2571?vs=6404=6407

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

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
@@ -45,6 +45,7 @@
   > # This is "force" in hex.
   > heads 666f726365
   > PUSHFILE ../initial.v1.hg
+  > readavailable
   > EOF
   testing ssh1
   creating ssh peer from handshake results
@@ -87,17 +88,15 @@
   i> flush() -> None
   o> readline() -> 2:
   o> 0\n
-  e> read(-1) -> 115:
-  e> abort: incompatible Mercurial client; bundle2 required\n
-  e> (see https://www.mercurial-scm.org/wiki/IncompatibleClient)\n
-  remote: abort: incompatible Mercurial client; bundle2 required
-  remote: (see https://www.mercurial-scm.org/wiki/IncompatibleClient)
   o> read(0) -> 0: 
   o> readline() -> 2:
   o> 1\n
   o> read(1) -> 1: 0
   result: 0
   remote output: 
+  e> read(-1) -> 115:
+  e> abort: incompatible Mercurial client; bundle2 required\n
+  e> (see https://www.mercurial-scm.org/wiki/IncompatibleClient)\n
   
   testing ssh2
   creating ssh peer from handshake results
@@ -140,17 +139,15 @@
   i> flush() -> None
   o> readline() -> 2:
   o> 0\n
-  e> read(-1) -> 115:
-  e> abort: incompatible Mercurial client; bundle2 required\n
-  e> (see https://www.mercurial-scm.org/wiki/IncompatibleClient)\n
-  remote: abort: incompatible Mercurial client; bundle2 required
-  remote: (see https://www.mercurial-scm.org/wiki/IncompatibleClient)
   o> read(0) -> 0: 
   o> readline() -> 2:
   o> 1\n
   o> read(1) -> 1: 0
   result: 0
   remote output: 
+  e> read(-1) -> 115:
+  e> abort: incompatible Mercurial client; bundle2 required\n
+  e> (see https://www.mercurial-scm.org/wiki/IncompatibleClient)\n
 
   $ cd ..
 
@@ -217,6 +214,7 @@
   > # This is "force" in hex.
   > heads 666f726365
   > PUSHFILE ../initial.v1.hg
+  > readavailable
   > EOF
   testing ssh1
   creating ssh peer from handshake results
@@ -259,6 +257,12 @@
   i> flush() -> None
   o> readline() -> 2:
   o> 0\n
+  o> read(0) -> 0: 
+  o> readline() -> 2:
+  o> 1\n
+  o> read(1) -> 1: 0
+  result: 0
+  remote output: 
   e> read(-1) -> 196:
   e> adding changesets\n
   e> adding manifests\n
@@ -268,20 +272,6 @@
   e> transaction abort!\n
   e> rollback completed\n
   e> abort: pretxnchangegroup.fail hook failed\n
-  remote: adding changesets
-  remote: adding manifests
-  remote: adding file changes
-  remote: added 1 changesets with 1 changes to 1 files
-  remote: ui.write 1 line
-  remote: transaction abort!
-  remote: rollback completed
-  remote: abort: pretxnchangegroup.fail hook failed
-  o> read(0) -> 0: 
-  o> readline() -> 2:
-  o> 1\n
-  o> read(1) -> 1: 0
-  result: 0
-  remote output: 
   
   testing ssh2
   creating ssh peer from handshake results
@@ -324,6 +314,12 @@
   i> flush() -> None
   o> readline() -> 2:
   o> 0\n
+  o> read(0) -> 0: 
+  o> readline() -> 2:
+  o> 1\n
+  o> read(1) -> 1: 0
+  result: 0
+  remote output: 
   e> read(-1) -> 196:
   e> adding changesets\n
   e> adding manifests\n
@@ -333,20 +329,6 @@
   e> transaction abort!\n
   e> rollback completed\n
   e> abort: pretxnchangegroup.fail hook failed\n
-  remote: adding changesets
-  remote: adding manifests
-  remote: adding file changes
-  remote: added 1 changesets with 1 changes to 1 files
-  remote: ui.write 1 line
-  remote: transaction abort!
-  remote: rollback completed
-  remote: abort: pretxnchangegroup.fail hook failed
-  o> read(0) -> 0: 
-  o> readline() -> 2:
-  o> 1\n
-  o> read(1) -> 1: 0
-  result: 0
-  remote output: 
 
 And a variation that writes multiple lines using ui.write
 
@@ -360,6 +342,7 @@
   > # This is "force" in hex.
   > heads 666f726365
   > PUSHFILE ../initial.v1.hg
+  > readavailable
   > EOF
   testing ssh1
   creating ssh peer from handshake results
@@ -402,6 +385,12 @@
   i> flush() -> None
   o> readline() -> 2:
   o> 0\n
+  o> read(0) -> 0: 
+  o> readline() -> 2:
+  o> 1\n
+  o> read(1) -> 1: 0
+  result: 0
+  remote output: 
   e> read(-1) -> 218:
   e> adding changesets\n
   e> adding manifests\n
@@ -412,21 +401,6 @@
   e> transaction abort!\n
   e> rollback completed\n
   e> abort: pretxnchangegroup.fail hook failed\n
-  remote: adding changesets
-  remote: adding manifests
-  remote: adding file changes
-  remote: added 1 changesets with 1 changes to 1 files
-  remote: ui.write 2 lines 1
-  remote: ui.write 2 lines 2
-  remote: transaction abort!
-  remote: 

D2571: sshpeer: don't read from stderr when that behavior is disabled

2018-03-02 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We previously prevented the creation of doublepipe instances when
  we're not supposed to automatically read from stderr. However,
  there were other automatic calls to read from stderr that were
  undermining this effort.
  
  This commit prevents all automatic reads from stderr from occurring
  when they are supposed to be disabled.
  
  Because stderr is no longer being read, we need to call "readavailable"
  from tests so stderr is read from.
  
  Test output changes because stderr is now always (manually) read after
  stdout. And, since sshpeer no longer automatically tends to stderr,
  no "remote: " messages are printed. This should fix non-deterministic
  test output.
  
  FWIW, doublepipe automatically reads from stderr when reading from
  stdout, so I'm not sure some of these calls to self._readerr() are
  even needed.

REPOSITORY
  rHG Mercurial

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

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
@@ -45,6 +45,7 @@
   > # This is "force" in hex.
   > heads 666f726365
   > PUSHFILE ../initial.v1.hg
+  > readavailable
   > EOF
   testing ssh1
   creating ssh peer from handshake results
@@ -87,17 +88,15 @@
   i> flush() -> None
   o> readline() -> 2:
   o> 0\n
-  e> read(-1) -> 115:
-  e> abort: incompatible Mercurial client; bundle2 required\n
-  e> (see https://www.mercurial-scm.org/wiki/IncompatibleClient)\n
-  remote: abort: incompatible Mercurial client; bundle2 required
-  remote: (see https://www.mercurial-scm.org/wiki/IncompatibleClient)
   o> read(0) -> 0: 
   o> readline() -> 2:
   o> 1\n
   o> read(1) -> 1: 0
   result: 0
   remote output: 
+  e> read(-1) -> 115:
+  e> abort: incompatible Mercurial client; bundle2 required\n
+  e> (see https://www.mercurial-scm.org/wiki/IncompatibleClient)\n
   
   testing ssh2
   creating ssh peer from handshake results
@@ -140,17 +139,15 @@
   i> flush() -> None
   o> readline() -> 2:
   o> 0\n
-  e> read(-1) -> 115:
-  e> abort: incompatible Mercurial client; bundle2 required\n
-  e> (see https://www.mercurial-scm.org/wiki/IncompatibleClient)\n
-  remote: abort: incompatible Mercurial client; bundle2 required
-  remote: (see https://www.mercurial-scm.org/wiki/IncompatibleClient)
   o> read(0) -> 0: 
   o> readline() -> 2:
   o> 1\n
   o> read(1) -> 1: 0
   result: 0
   remote output: 
+  e> read(-1) -> 115:
+  e> abort: incompatible Mercurial client; bundle2 required\n
+  e> (see https://www.mercurial-scm.org/wiki/IncompatibleClient)\n
 
   $ cd ..
 
@@ -217,6 +214,7 @@
   > # This is "force" in hex.
   > heads 666f726365
   > PUSHFILE ../initial.v1.hg
+  > readavailable
   > EOF
   testing ssh1
   creating ssh peer from handshake results
@@ -259,6 +257,12 @@
   i> flush() -> None
   o> readline() -> 2:
   o> 0\n
+  o> read(0) -> 0: 
+  o> readline() -> 2:
+  o> 1\n
+  o> read(1) -> 1: 0
+  result: 0
+  remote output: 
   e> read(-1) -> 196:
   e> adding changesets\n
   e> adding manifests\n
@@ -268,20 +272,6 @@
   e> transaction abort!\n
   e> rollback completed\n
   e> abort: pretxnchangegroup.fail hook failed\n
-  remote: adding changesets
-  remote: adding manifests
-  remote: adding file changes
-  remote: added 1 changesets with 1 changes to 1 files
-  remote: ui.write 1 line
-  remote: transaction abort!
-  remote: rollback completed
-  remote: abort: pretxnchangegroup.fail hook failed
-  o> read(0) -> 0: 
-  o> readline() -> 2:
-  o> 1\n
-  o> read(1) -> 1: 0
-  result: 0
-  remote output: 
   
   testing ssh2
   creating ssh peer from handshake results
@@ -324,6 +314,12 @@
   i> flush() -> None
   o> readline() -> 2:
   o> 0\n
+  o> read(0) -> 0: 
+  o> readline() -> 2:
+  o> 1\n
+  o> read(1) -> 1: 0
+  result: 0
+  remote output: 
   e> read(-1) -> 196:
   e> adding changesets\n
   e> adding manifests\n
@@ -333,20 +329,6 @@
   e> transaction abort!\n
   e> rollback completed\n
   e> abort: pretxnchangegroup.fail hook failed\n
-  remote: adding changesets
-  remote: adding manifests
-  remote: adding file changes
-  remote: added 1 changesets with 1 changes to 1 files
-  remote: ui.write 1 line
-  remote: transaction abort!
-  remote: rollback completed
-  remote: abort: pretxnchangegroup.fail hook failed
-  o> read(0) -> 0: 
-  o> readline() -> 2:
-  o> 1\n
-  o> read(1) -> 1: 0
-  result: 0
-  remote output: 
 
 And a variation that writes multiple lines using ui.write
 
@@ -360,6 +342,7 @@
   > # This is "force" in hex.
   > heads 666f726365
   > PUSHFILE ../initial.v1.hg
+  > readavailable
   > EOF
   testing ssh1
   creating