mercurial/dispatch.py
changeset 37994 e9c588802529
parent 37944 dc1ed7fe33e4
child 37995 6f9ac3cb0987
equal deleted inserted replaced
37993:623dc2651d26 37994:e9c588802529
    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:
    92         err = e
    92         err = e
    93         status = -1
    93         status = -1
       
    94 
       
    95     # In all cases we try to flush stdio streams.
    94     if util.safehasattr(req.ui, 'fout'):
    96     if util.safehasattr(req.ui, 'fout'):
    95         try:
    97         try:
    96             req.ui.fout.flush()
    98             req.ui.fout.flush()
    97         except IOError as e:
    99         except IOError as e:
    98             err = e
   100             err = e
    99             status = -1
   101             status = -1
       
   102 
   100     if util.safehasattr(req.ui, 'ferr'):
   103     if util.safehasattr(req.ui, 'ferr'):
   101         try:
   104         try:
   102             if err is not None and err.errno != errno.EPIPE:
   105             if err is not None and err.errno != errno.EPIPE:
   103                 req.ui.ferr.write('abort: %s\n' %
   106                 req.ui.ferr.write('abort: %s\n' %
   104                                   encoding.strtolocal(err.strerror))
   107                                   encoding.strtolocal(err.strerror))