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