##// END OF EJS Templates
dispatch: move IOError handling and flushing of streams to `dispatch()`...
Pulkit Goyal -
r46717:49b69102 default
parent child Browse files
Show More
@@ -355,18 +355,7 b' class server(object):'
355 355 )
356 356
357 357 try:
358 err = None
359 try:
360 status = self._dispatchcommand(req)
361 except error.StdioError as e:
362 status = -1
363 err = e
364
365 retval = dispatch.closestdio(req.ui, err)
366 if retval:
367 status = retval
368
369 ret = status & 255
358 ret = self._dispatchcommand(req) & 255
370 359 # If shutdown-on-interrupt is off, it's important to write the
371 360 # result code *after* SIGINT handler removed. If the result code
372 361 # were lost, the client wouldn't be able to continue processing.
@@ -104,7 +104,7 b' class request(object):'
104 104 raise exc
105 105
106 106
107 def closestdio(ui, err):
107 def _flushstdio(ui, err):
108 108 status = None
109 109 # In all cases we try to flush stdio streams.
110 110 if util.safehasattr(ui, b'fout'):
@@ -139,16 +139,8 b' def run():'
139 139 initstdio()
140 140 with tracing.log('parse args into request'):
141 141 req = request(pycompat.sysargv[1:])
142 err = None
143 try:
144 status = dispatch(req)
145 except error.StdioError as e:
146 err = e
147 status = -1
148 142
149 ret = closestdio(req.ui, err)
150 if ret:
151 status = ret
143 status = dispatch(req)
152 144 _silencestdio()
153 145 except KeyboardInterrupt:
154 146 # Catch early/late KeyboardInterrupt as last ditch. Here nothing will
@@ -240,7 +232,21 b' def _formatargs(args):'
240 232
241 233 def dispatch(req):
242 234 """run the command specified in req.args; returns an integer status code"""
243 with tracing.log('dispatch.dispatch'):
235 err = None
236 try:
237 status = _rundispatch(req)
238 except error.StdioError as e:
239 err = e
240 status = -1
241
242 ret = _flushstdio(req.ui, err)
243 if ret:
244 status = ret
245 return status
246
247
248 def _rundispatch(req):
249 with tracing.log('dispatch._rundispatch'):
244 250 if req.ferr:
245 251 ferr = req.ferr
246 252 elif req.ui:
@@ -104,6 +104,7 b''
104 104 */hg:* in <module> (glob) (?)
105 105 */mercurial/dispatch.py:* in run (glob)
106 106 */mercurial/dispatch.py:* in dispatch (glob)
107 */mercurial/dispatch.py:* in _rundispatch (glob)
107 108 */mercurial/dispatch.py:* in _runcatch (glob)
108 109 */mercurial/dispatch.py:* in _callcatch (glob)
109 110 */mercurial/scmutil.py* in callcatch (glob)
@@ -120,6 +121,7 b''
120 121 */hg:* in <module> (glob) (?)
121 122 */mercurial/dispatch.py:* in run (glob)
122 123 */mercurial/dispatch.py:* in dispatch (glob)
124 */mercurial/dispatch.py:* in _rundispatch (glob)
123 125 */mercurial/dispatch.py:* in _runcatch (glob)
124 126 */mercurial/dispatch.py:* in _callcatch (glob)
125 127 */mercurial/scmutil.py:* in callcatch (glob)
@@ -142,6 +144,7 b''
142 144 */mercurial/commandserver.py:* in runcommand (glob)
143 145 */mercurial/commandserver.py:* in _dispatchcommand (glob)
144 146 */mercurial/dispatch.py:* in dispatch (glob)
147 */mercurial/dispatch.py:* in _rundispatch (glob)
145 148 */mercurial/dispatch.py:* in _runcatch (glob)
146 149 */mercurial/dispatch.py:* in _callcatch (glob)
147 150 */mercurial/scmutil.py:* in callcatch (glob)
@@ -184,6 +187,7 b' Stripping from a transaction'
184 187 */hg:* in <module> (glob) (?)
185 188 */mercurial/dispatch.py:* in run (glob)
186 189 */mercurial/dispatch.py:* in dispatch (glob)
190 */mercurial/dispatch.py:* in _rundispatch (glob)
187 191 */mercurial/dispatch.py:* in _runcatch (glob)
188 192 */mercurial/dispatch.py:* in _callcatch (glob)
189 193 */mercurial/scmutil.py* in callcatch (glob)
@@ -201,6 +205,7 b' Stripping from a transaction'
201 205 */hg:* in <module> (glob)
202 206 */mercurial/dispatch.py:* in run (glob)
203 207 */mercurial/dispatch.py:* in dispatch (glob)
208 */mercurial/dispatch.py:* in _rundispatch (glob)
204 209 */mercurial/dispatch.py:* in _runcatch (glob)
205 210 */mercurial/dispatch.py:* in _callcatch (glob)
206 211 */mercurial/scmutil.py:* in callcatch (glob)
@@ -223,6 +228,7 b' Stripping from a transaction'
223 228 */mercurial/commandserver.py:* in runcommand (glob)
224 229 */mercurial/commandserver.py:* in _dispatchcommand (glob)
225 230 */mercurial/dispatch.py:* in dispatch (glob)
231 */mercurial/dispatch.py:* in _rundispatch (glob)
226 232 */mercurial/dispatch.py:* in _runcatch (glob)
227 233 */mercurial/dispatch.py:* in _callcatch (glob)
228 234 */mercurial/scmutil.py:* in callcatch (glob)
@@ -247,6 +253,7 b' Stripping from a transaction'
247 253 */hg:* in <module> (glob) (?)
248 254 */mercurial/dispatch.py:* in run (glob)
249 255 */mercurial/dispatch.py:* in dispatch (glob)
256 */mercurial/dispatch.py:* in _rundispatch (glob)
250 257 */mercurial/dispatch.py:* in _runcatch (glob)
251 258 */mercurial/dispatch.py:* in _callcatch (glob)
252 259 */mercurial/scmutil.py* in callcatch (glob)
@@ -271,6 +278,7 b' Stripping from a transaction'
271 278 */hg:* in <module> (glob)
272 279 */mercurial/dispatch.py:* in run (glob)
273 280 */mercurial/dispatch.py:* in dispatch (glob)
281 */mercurial/dispatch.py:* in _rundispatch (glob)
274 282 */mercurial/dispatch.py:* in _runcatch (glob)
275 283 */mercurial/dispatch.py:* in _callcatch (glob)
276 284 */mercurial/scmutil.py:* in callcatch (glob)
@@ -293,6 +301,7 b' Stripping from a transaction'
293 301 */mercurial/commandserver.py:* in runcommand (glob)
294 302 */mercurial/commandserver.py:* in _dispatchcommand (glob)
295 303 */mercurial/dispatch.py:* in dispatch (glob)
304 */mercurial/dispatch.py:* in _rundispatch (glob)
296 305 */mercurial/dispatch.py:* in _runcatch (glob)
297 306 */mercurial/dispatch.py:* in _callcatch (glob)
298 307 */mercurial/scmutil.py:* in callcatch (glob)
General Comments 0
You need to be logged in to leave comments. Login now