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