Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/dispatch.py @ 37988: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 | 0664be4f0c1f |
children | e9c588802529 |
comparison
equal
deleted
inserted
replaced
37987:45a669bad421 | 37988:dc1ed7fe33e4 |
---|---|
81 if exc is not None: | 81 if exc is not None: |
82 raise exc | 82 raise exc |
83 | 83 |
84 def run(): | 84 def run(): |
85 "run the command in sys.argv" | 85 "run the command in sys.argv" |
86 _initstdio() | 86 initstdio() |
87 req = request(pycompat.sysargv[1:]) | 87 req = request(pycompat.sysargv[1:]) |
88 err = None | 88 err = None |
89 try: | 89 try: |
90 status = (dispatch(req) or 0) | 90 status = (dispatch(req) or 0) |
91 except error.StdioError as e: | 91 except error.StdioError as e: |
110 | 110 |
111 _silencestdio() | 111 _silencestdio() |
112 sys.exit(status & 255) | 112 sys.exit(status & 255) |
113 | 113 |
114 if pycompat.ispy3: | 114 if pycompat.ispy3: |
115 def _initstdio(): | 115 def initstdio(): |
116 pass | 116 pass |
117 | 117 |
118 def _silencestdio(): | 118 def _silencestdio(): |
119 for fp in (sys.stdout, sys.stderr): | 119 for fp in (sys.stdout, sys.stderr): |
120 # Check if the file is okay | 120 # Check if the file is okay |
130 try: | 130 try: |
131 fp.close() | 131 fp.close() |
132 except IOError: | 132 except IOError: |
133 pass | 133 pass |
134 else: | 134 else: |
135 def _initstdio(): | 135 def initstdio(): |
136 for fp in (sys.stdin, sys.stdout, sys.stderr): | 136 for fp in (sys.stdin, sys.stdout, sys.stderr): |
137 procutil.setbinary(fp) | 137 procutil.setbinary(fp) |
138 | 138 |
139 def _silencestdio(): | 139 def _silencestdio(): |
140 pass | 140 pass |