Show More
@@ -117,6 +117,7 b' except ImportError:' | |||||
117 | 'formatvariant.config.default': 'green', |
|
117 | 'formatvariant.config.default': 'green', | |
118 | 'formatvariant.default': '', |
|
118 | 'formatvariant.default': '', | |
119 | 'histedit.remaining': 'red bold', |
|
119 | 'histedit.remaining': 'red bold', | |
|
120 | 'ui.error': 'red', | |||
120 | 'ui.prompt': 'yellow', |
|
121 | 'ui.prompt': 'yellow', | |
121 | 'log.changeset': 'yellow', |
|
122 | 'log.changeset': 'yellow', | |
122 | 'patchbomb.finalsummary': '', |
|
123 | 'patchbomb.finalsummary': '', |
@@ -353,7 +353,7 b' def _serverequest(ui, repo, conn, create' | |||||
353 | # handle exceptions that may be raised by command server. most of |
|
353 | # handle exceptions that may be raised by command server. most of | |
354 | # known exceptions are caught by dispatch. |
|
354 | # known exceptions are caught by dispatch. | |
355 | except error.Abort as inst: |
|
355 | except error.Abort as inst: | |
356 |
ui. |
|
356 | ui.error(_('abort: %s\n') % inst) | |
357 | except IOError as inst: |
|
357 | except IOError as inst: | |
358 | if inst.errno != errno.EPIPE: |
|
358 | if inst.errno != errno.EPIPE: | |
359 | raise |
|
359 | raise |
@@ -212,9 +212,9 b' def dispatch(req):' | |||||
212 | try: |
|
212 | try: | |
213 | ret = _runcatch(req) or 0 |
|
213 | ret = _runcatch(req) or 0 | |
214 | except error.ProgrammingError as inst: |
|
214 | except error.ProgrammingError as inst: | |
215 |
req.ui. |
|
215 | req.ui.error(_('** ProgrammingError: %s\n') % inst) | |
216 | if inst.hint: |
|
216 | if inst.hint: | |
217 |
req.ui. |
|
217 | req.ui.error(_('** (%s)\n') % inst.hint) | |
218 | raise |
|
218 | raise | |
219 | except KeyboardInterrupt as inst: |
|
219 | except KeyboardInterrupt as inst: | |
220 | try: |
|
220 | try: | |
@@ -222,7 +222,7 b' def dispatch(req):' | |||||
222 | msg = _("killed!\n") |
|
222 | msg = _("killed!\n") | |
223 | else: |
|
223 | else: | |
224 | msg = _("interrupted!\n") |
|
224 | msg = _("interrupted!\n") | |
225 |
req.ui. |
|
225 | req.ui.error(msg) | |
226 | except error.SignalInterrupt: |
|
226 | except error.SignalInterrupt: | |
227 | # maybe pager would quit without consuming all the output, and |
|
227 | # maybe pager would quit without consuming all the output, and | |
228 | # SIGPIPE was raised. we cannot print anything in this case. |
|
228 | # SIGPIPE was raised. we cannot print anything in this case. |
@@ -169,64 +169,64 b' def callcatch(ui, func):' | |||||
169 | reason = _('timed out waiting for lock held by %r') % inst.locker |
|
169 | reason = _('timed out waiting for lock held by %r') % inst.locker | |
170 | else: |
|
170 | else: | |
171 | reason = _('lock held by %r') % inst.locker |
|
171 | reason = _('lock held by %r') % inst.locker | |
172 |
ui. |
|
172 | ui.error(_("abort: %s: %s\n") % ( | |
173 |
|
|
173 | inst.desc or stringutil.forcebytestr(inst.filename), reason)) | |
174 | if not inst.locker: |
|
174 | if not inst.locker: | |
175 |
ui. |
|
175 | ui.error(_("(lock might be very busy)\n")) | |
176 | except error.LockUnavailable as inst: |
|
176 | except error.LockUnavailable as inst: | |
177 |
ui. |
|
177 | ui.error(_("abort: could not lock %s: %s\n") % | |
178 | (inst.desc or stringutil.forcebytestr(inst.filename), |
|
178 | (inst.desc or stringutil.forcebytestr(inst.filename), | |
179 | encoding.strtolocal(inst.strerror))) |
|
179 | encoding.strtolocal(inst.strerror))) | |
180 | except error.OutOfBandError as inst: |
|
180 | except error.OutOfBandError as inst: | |
181 | if inst.args: |
|
181 | if inst.args: | |
182 | msg = _("abort: remote error:\n") |
|
182 | msg = _("abort: remote error:\n") | |
183 | else: |
|
183 | else: | |
184 | msg = _("abort: remote error\n") |
|
184 | msg = _("abort: remote error\n") | |
185 |
ui. |
|
185 | ui.error(msg) | |
186 | if inst.args: |
|
186 | if inst.args: | |
187 |
ui. |
|
187 | ui.error(''.join(inst.args)) | |
188 | if inst.hint: |
|
188 | if inst.hint: | |
189 |
ui. |
|
189 | ui.error('(%s)\n' % inst.hint) | |
190 | except error.RepoError as inst: |
|
190 | except error.RepoError as inst: | |
191 |
ui. |
|
191 | ui.error(_("abort: %s!\n") % inst) | |
192 | if inst.hint: |
|
192 | if inst.hint: | |
193 |
ui. |
|
193 | ui.error(_("(%s)\n") % inst.hint) | |
194 | except error.ResponseError as inst: |
|
194 | except error.ResponseError as inst: | |
195 |
ui. |
|
195 | ui.error(_("abort: %s") % inst.args[0]) | |
196 | msg = inst.args[1] |
|
196 | msg = inst.args[1] | |
197 | if isinstance(msg, type(u'')): |
|
197 | if isinstance(msg, type(u'')): | |
198 | msg = pycompat.sysbytes(msg) |
|
198 | msg = pycompat.sysbytes(msg) | |
199 | if not isinstance(msg, bytes): |
|
199 | if not isinstance(msg, bytes): | |
200 |
ui. |
|
200 | ui.error(" %r\n" % (msg,)) | |
201 | elif not msg: |
|
201 | elif not msg: | |
202 |
ui. |
|
202 | ui.error(_(" empty string\n")) | |
203 | else: |
|
203 | else: | |
204 |
ui. |
|
204 | ui.error("\n%r\n" % pycompat.bytestr(stringutil.ellipsis(msg))) | |
205 | except error.CensoredNodeError as inst: |
|
205 | except error.CensoredNodeError as inst: | |
206 |
ui. |
|
206 | ui.error(_("abort: file censored %s!\n") % inst) | |
207 | except error.RevlogError as inst: |
|
207 | except error.RevlogError as inst: | |
208 |
ui. |
|
208 | ui.error(_("abort: %s!\n") % inst) | |
209 | except error.InterventionRequired as inst: |
|
209 | except error.InterventionRequired as inst: | |
210 |
ui. |
|
210 | ui.error("%s\n" % inst) | |
211 | if inst.hint: |
|
211 | if inst.hint: | |
212 |
ui. |
|
212 | ui.error(_("(%s)\n") % inst.hint) | |
213 | return 1 |
|
213 | return 1 | |
214 | except error.WdirUnsupported: |
|
214 | except error.WdirUnsupported: | |
215 |
ui. |
|
215 | ui.error(_("abort: working directory revision cannot be specified\n")) | |
216 | except error.Abort as inst: |
|
216 | except error.Abort as inst: | |
217 |
ui. |
|
217 | ui.error(_("abort: %s\n") % inst) | |
218 | if inst.hint: |
|
218 | if inst.hint: | |
219 |
ui. |
|
219 | ui.error(_("(%s)\n") % inst.hint) | |
220 | except ImportError as inst: |
|
220 | except ImportError as inst: | |
221 |
ui. |
|
221 | ui.error(_("abort: %s!\n") % stringutil.forcebytestr(inst)) | |
222 | m = stringutil.forcebytestr(inst).split()[-1] |
|
222 | m = stringutil.forcebytestr(inst).split()[-1] | |
223 | if m in "mpatch bdiff".split(): |
|
223 | if m in "mpatch bdiff".split(): | |
224 |
ui. |
|
224 | ui.error(_("(did you forget to compile extensions?)\n")) | |
225 | elif m in "zlib".split(): |
|
225 | elif m in "zlib".split(): | |
226 |
ui. |
|
226 | ui.error(_("(is your Python install correct?)\n")) | |
227 | except IOError as inst: |
|
227 | except IOError as inst: | |
228 | if util.safehasattr(inst, "code"): |
|
228 | if util.safehasattr(inst, "code"): | |
229 |
ui. |
|
229 | ui.error(_("abort: %s\n") % stringutil.forcebytestr(inst)) | |
230 | elif util.safehasattr(inst, "reason"): |
|
230 | elif util.safehasattr(inst, "reason"): | |
231 | try: # usually it is in the form (errno, strerror) |
|
231 | try: # usually it is in the form (errno, strerror) | |
232 | reason = inst.reason.args[1] |
|
232 | reason = inst.reason.args[1] | |
@@ -236,34 +236,34 b' def callcatch(ui, func):' | |||||
236 | if isinstance(reason, pycompat.unicode): |
|
236 | if isinstance(reason, pycompat.unicode): | |
237 | # SSLError of Python 2.7.9 contains a unicode |
|
237 | # SSLError of Python 2.7.9 contains a unicode | |
238 | reason = encoding.unitolocal(reason) |
|
238 | reason = encoding.unitolocal(reason) | |
239 |
ui. |
|
239 | ui.error(_("abort: error: %s\n") % reason) | |
240 | elif (util.safehasattr(inst, "args") |
|
240 | elif (util.safehasattr(inst, "args") | |
241 | and inst.args and inst.args[0] == errno.EPIPE): |
|
241 | and inst.args and inst.args[0] == errno.EPIPE): | |
242 | pass |
|
242 | pass | |
243 | elif getattr(inst, "strerror", None): |
|
243 | elif getattr(inst, "strerror", None): | |
244 | if getattr(inst, "filename", None): |
|
244 | if getattr(inst, "filename", None): | |
245 |
ui. |
|
245 | ui.error(_("abort: %s: %s\n") % ( | |
246 | encoding.strtolocal(inst.strerror), |
|
246 | encoding.strtolocal(inst.strerror), | |
247 | stringutil.forcebytestr(inst.filename))) |
|
247 | stringutil.forcebytestr(inst.filename))) | |
248 | else: |
|
248 | else: | |
249 |
ui. |
|
249 | ui.error(_("abort: %s\n") % encoding.strtolocal(inst.strerror)) | |
250 | else: |
|
250 | else: | |
251 | raise |
|
251 | raise | |
252 | except OSError as inst: |
|
252 | except OSError as inst: | |
253 | if getattr(inst, "filename", None) is not None: |
|
253 | if getattr(inst, "filename", None) is not None: | |
254 |
ui. |
|
254 | ui.error(_("abort: %s: '%s'\n") % ( | |
255 | encoding.strtolocal(inst.strerror), |
|
255 | encoding.strtolocal(inst.strerror), | |
256 | stringutil.forcebytestr(inst.filename))) |
|
256 | stringutil.forcebytestr(inst.filename))) | |
257 | else: |
|
257 | else: | |
258 |
ui. |
|
258 | ui.error(_("abort: %s\n") % encoding.strtolocal(inst.strerror)) | |
259 | except MemoryError: |
|
259 | except MemoryError: | |
260 |
ui. |
|
260 | ui.error(_("abort: out of memory\n")) | |
261 | except SystemExit as inst: |
|
261 | except SystemExit as inst: | |
262 | # Commands shouldn't sys.exit directly, but give a return code. |
|
262 | # Commands shouldn't sys.exit directly, but give a return code. | |
263 | # Just in case catch this and and pass exit code to caller. |
|
263 | # Just in case catch this and and pass exit code to caller. | |
264 | return inst.code |
|
264 | return inst.code | |
265 | except socket.error as inst: |
|
265 | except socket.error as inst: | |
266 |
ui. |
|
266 | ui.error(_("abort: %s\n") % stringutil.forcebytestr(inst.args[-1])) | |
267 |
|
267 | |||
268 | return -1 |
|
268 | return -1 | |
269 |
|
269 |
@@ -1420,6 +1420,7 b' class ui(object):' | |||||
1420 | return getpass.getpass('') |
|
1420 | return getpass.getpass('') | |
1421 | except EOFError: |
|
1421 | except EOFError: | |
1422 | raise error.ResponseExpected() |
|
1422 | raise error.ResponseExpected() | |
|
1423 | ||||
1423 | def status(self, *msg, **opts): |
|
1424 | def status(self, *msg, **opts): | |
1424 | '''write status message to output (if ui.quiet is False) |
|
1425 | '''write status message to output (if ui.quiet is False) | |
1425 |
|
1426 | |||
@@ -1428,6 +1429,7 b' class ui(object):' | |||||
1428 | if not self.quiet: |
|
1429 | if not self.quiet: | |
1429 | opts[r'label'] = opts.get(r'label', '') + ' ui.status' |
|
1430 | opts[r'label'] = opts.get(r'label', '') + ' ui.status' | |
1430 | self.write(*msg, **opts) |
|
1431 | self.write(*msg, **opts) | |
|
1432 | ||||
1431 | def warn(self, *msg, **opts): |
|
1433 | def warn(self, *msg, **opts): | |
1432 | '''write warning message to output (stderr) |
|
1434 | '''write warning message to output (stderr) | |
1433 |
|
1435 | |||
@@ -1435,6 +1437,15 b' class ui(object):' | |||||
1435 | ''' |
|
1437 | ''' | |
1436 | opts[r'label'] = opts.get(r'label', '') + ' ui.warning' |
|
1438 | opts[r'label'] = opts.get(r'label', '') + ' ui.warning' | |
1437 | self.write_err(*msg, **opts) |
|
1439 | self.write_err(*msg, **opts) | |
|
1440 | ||||
|
1441 | def error(self, *msg, **opts): | |||
|
1442 | '''write error message to output (stderr) | |||
|
1443 | ||||
|
1444 | This adds an output label of "ui.error". | |||
|
1445 | ''' | |||
|
1446 | opts[r'label'] = opts.get(r'label', '') + ' ui.error' | |||
|
1447 | self.write_err(*msg, **opts) | |||
|
1448 | ||||
1438 | def note(self, *msg, **opts): |
|
1449 | def note(self, *msg, **opts): | |
1439 | '''write note to output (if ui.verbose is True) |
|
1450 | '''write note to output (if ui.verbose is True) | |
1440 |
|
1451 | |||
@@ -1443,6 +1454,7 b' class ui(object):' | |||||
1443 | if self.verbose: |
|
1454 | if self.verbose: | |
1444 | opts[r'label'] = opts.get(r'label', '') + ' ui.note' |
|
1455 | opts[r'label'] = opts.get(r'label', '') + ' ui.note' | |
1445 | self.write(*msg, **opts) |
|
1456 | self.write(*msg, **opts) | |
|
1457 | ||||
1446 | def debug(self, *msg, **opts): |
|
1458 | def debug(self, *msg, **opts): | |
1447 | '''write debug message to output (if ui.debugflag is True) |
|
1459 | '''write debug message to output (if ui.debugflag is True) | |
1448 |
|
1460 |
General Comments 0
You need to be logged in to leave comments.
Login now