changeset 37944:dc1ed7fe33e4

sshserver: do setbinary() by caller (API) In most cases, stdio should be set to binary mode by the dispatcher, so the sshserver does not have to take care of that. The only exception was hg-ssh, which is fixed by this patch. .. api:: ``sshserver()`` no longer sets stdin and stdout to binary mode.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 25 Mar 2018 16:35:24 +0900
parents 45a669bad421
children bfe8ef6e370e
files contrib/hg-ssh mercurial/dispatch.py mercurial/wireprotoserver.py
diffstat 3 files changed, 6 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/hg-ssh	Sun Mar 25 16:39:17 2018 +0900
+++ b/contrib/hg-ssh	Sun Mar 25 16:35:24 2018 +0900
@@ -43,6 +43,9 @@
 )
 
 def main():
+    # Prevent insertion/deletion of CRs
+    dispatch.initstdio()
+
     cwd = os.getcwd()
     readonly = False
     args = sys.argv[1:]
--- a/mercurial/dispatch.py	Sun Mar 25 16:39:17 2018 +0900
+++ b/mercurial/dispatch.py	Sun Mar 25 16:35:24 2018 +0900
@@ -83,7 +83,7 @@
 
 def run():
     "run the command in sys.argv"
-    _initstdio()
+    initstdio()
     req = request(pycompat.sysargv[1:])
     err = None
     try:
@@ -112,7 +112,7 @@
     sys.exit(status & 255)
 
 if pycompat.ispy3:
-    def _initstdio():
+    def initstdio():
         pass
 
     def _silencestdio():
@@ -132,7 +132,7 @@
             except IOError:
                 pass
 else:
-    def _initstdio():
+    def initstdio():
         for fp in (sys.stdin, sys.stdout, sys.stderr):
             procutil.setbinary(fp)
 
--- a/mercurial/wireprotoserver.py	Sun Mar 25 16:39:17 2018 +0900
+++ b/mercurial/wireprotoserver.py	Sun Mar 25 16:35:24 2018 +0900
@@ -798,10 +798,6 @@
         hook.redirect(True)
         ui.fout = repo.ui.fout = ui.ferr
 
-        # Prevent insertion/deletion of CRs
-        procutil.setbinary(self._fin)
-        procutil.setbinary(self._fout)
-
     def serve_forever(self):
         self.serveuntil(threading.Event())
         sys.exit(0)