Show More
@@ -104,41 +104,44 b' class request(object):' | |||
|
104 | 104 | |
|
105 | 105 | def run(): |
|
106 | 106 | """run the command in sys.argv""" |
|
107 | initstdio() | |
|
108 | with tracing.log('parse args into request'): | |
|
109 | req = request(pycompat.sysargv[1:]) | |
|
110 | err = None | |
|
111 | 107 | try: |
|
112 | status = dispatch(req) | |
|
113 | except error.StdioError as e: | |
|
114 | err = e | |
|
115 | status = -1 | |
|
116 | ||
|
117 | # In all cases we try to flush stdio streams. | |
|
118 | if util.safehasattr(req.ui, b'fout'): | |
|
119 | assert req.ui is not None # help pytype | |
|
120 | assert req.ui.fout is not None # help pytype | |
|
108 | initstdio() | |
|
109 | with tracing.log('parse args into request'): | |
|
110 | req = request(pycompat.sysargv[1:]) | |
|
111 | err = None | |
|
121 | 112 | try: |
|
122 | req.ui.fout.flush() | |
|
123 |
except |
|
|
113 | status = dispatch(req) | |
|
114 | except error.StdioError as e: | |
|
124 | 115 | err = e |
|
125 | 116 | status = -1 |
|
126 | 117 | |
|
127 | if util.safehasattr(req.ui, b'ferr'): | |
|
128 | assert req.ui is not None # help pytype | |
|
129 |
assert req.ui |
|
|
130 | try: | |
|
131 | if err is not None and err.errno != errno.EPIPE: | |
|
132 |
req.ui.f |
|
|
133 | b'abort: %s\n' % encoding.strtolocal(err.strerror) | |
|
134 |
|
|
|
135 | req.ui.ferr.flush() | |
|
136 | # There's not much we can do about an I/O error here. So (possibly) | |
|
137 | # change the status code and move on. | |
|
138 | except IOError: | |
|
139 | status = -1 | |
|
118 | # In all cases we try to flush stdio streams. | |
|
119 | if util.safehasattr(req.ui, b'fout'): | |
|
120 | assert req.ui is not None # help pytype | |
|
121 | assert req.ui.fout is not None # help pytype | |
|
122 | try: | |
|
123 | req.ui.fout.flush() | |
|
124 | except IOError as e: | |
|
125 | err = e | |
|
126 | status = -1 | |
|
140 | 127 | |
|
141 | _silencestdio() | |
|
128 | if util.safehasattr(req.ui, b'ferr'): | |
|
129 | assert req.ui is not None # help pytype | |
|
130 | assert req.ui.ferr is not None # help pytype | |
|
131 | try: | |
|
132 | if err is not None and err.errno != errno.EPIPE: | |
|
133 | req.ui.ferr.write( | |
|
134 | b'abort: %s\n' % encoding.strtolocal(err.strerror) | |
|
135 | ) | |
|
136 | req.ui.ferr.flush() | |
|
137 | # There's not much we can do about an I/O error here. So (possibly) | |
|
138 | # change the status code and move on. | |
|
139 | except IOError: | |
|
140 | status = -1 | |
|
141 | ||
|
142 | _silencestdio() | |
|
143 | finally: | |
|
144 | pass | |
|
142 | 145 | sys.exit(status & 255) |
|
143 | 146 | |
|
144 | 147 |
General Comments 0
You need to be logged in to leave comments.
Login now