##// END OF EJS Templates
errors: name arguments to Abort constructor...
Martin von Zweigbergk -
r46274:d2e1dcd4 default
parent child Browse files
Show More
@@ -734,7 +734,7 b' def overridecopy(orig, ui, repo, pats, o'
734 734 try:
735 735 result = orig(ui, repo, pats, opts, rename)
736 736 except error.Abort as e:
737 if pycompat.bytestr(e) != _(b'no files to copy'):
737 if e.message != _(b'no files to copy'):
738 738 raise e
739 739 else:
740 740 nonormalfiles = True
@@ -851,7 +851,7 b' def overridecopy(orig, ui, repo, pats, o'
851 851 lfdirstate.add(destlfile)
852 852 lfdirstate.write()
853 853 except error.Abort as e:
854 if pycompat.bytestr(e) != _(b'no files to copy'):
854 if e.message != _(b'no files to copy'):
855 855 raise e
856 856 else:
857 857 nolfiles = True
@@ -13,7 +13,6 b' from mercurial import ('
13 13 extensions,
14 14 hg,
15 15 narrowspec,
16 pycompat,
17 16 wireprototypes,
18 17 wireprotov1peer,
19 18 wireprotov1server,
@@ -125,7 +124,7 b' def narrow_widen('
125 124 )
126 125 except error.Abort as exc:
127 126 bundler = bundle2.bundle20(repo.ui)
128 manargs = [(b'message', pycompat.bytestr(exc))]
127 manargs = [(b'message', exc.message)]
129 128 advargs = []
130 129 if exc.hint is not None:
131 130 advargs.append((b'hint', exc.hint))
@@ -2089,7 +2089,7 b' def handleremotechangegroup(op, inpart):'
2089 2089 except error.Abort as e:
2090 2090 raise error.Abort(
2091 2091 _(b'bundle at %s is corrupted:\n%s')
2092 % (util.hidepassword(raw_url), bytes(e))
2092 % (util.hidepassword(raw_url), e.message)
2093 2093 )
2094 2094 assert not inpart.read()
2095 2095
@@ -502,7 +502,7 b' class chgcmdserver(commandserver.server)'
502 502 self.cresult.write(b'exit 255')
503 503 return
504 504 except error.Abort as inst:
505 self.ui.error(_(b"abort: %s\n") % inst)
505 self.ui.error(_(b"abort: %s\n") % inst.message)
506 506 if inst.hint:
507 507 self.ui.error(_(b"(%s)\n") % inst.hint)
508 508 self.ui.flush()
@@ -500,7 +500,7 b' def _serverequest(ui, repo, conn, create'
500 500 # handle exceptions that may be raised by command server. most of
501 501 # known exceptions are caught by dispatch.
502 502 except error.Abort as inst:
503 ui.error(_(b'abort: %s\n') % inst)
503 ui.error(_(b'abort: %s\n') % inst.message)
504 504 except IOError as inst:
505 505 if inst.errno != errno.EPIPE:
506 506 raise
@@ -1808,7 +1808,7 b' are you sure you want to review/edit and'
1808 1808 try:
1809 1809 patch = self.ui.edit(patch.getvalue(), b"", action=b"diff")
1810 1810 except error.Abort as exc:
1811 self.errorstr = stringutil.forcebytestr(exc)
1811 self.errorstr = exc.message
1812 1812 return None
1813 1813 finally:
1814 1814 self.stdscr.clear()
@@ -1770,7 +1770,7 b' def debuginstall(ui, **opts):'
1770 1770 try:
1771 1771 username = ui.username()
1772 1772 except error.Abort as e:
1773 err = stringutil.forcebytestr(e)
1773 err = e.message
1774 1774 problems += 1
1775 1775
1776 1776 fm.condwrite(
@@ -288,7 +288,7 b' def dispatch(req):'
288 288 if req.fmsg:
289 289 req.ui.fmsg = req.fmsg
290 290 except error.Abort as inst:
291 ferr.write(_(b"abort: %s\n") % inst)
291 ferr.write(_(b"abort: %s\n") % inst.message)
292 292 if inst.hint:
293 293 ferr.write(_(b"(%s)\n") % inst.hint)
294 294 return -1
@@ -155,7 +155,15 b' class ConflictResolutionRequired(Interve'
155 155 class Abort(Hint, Exception):
156 156 """Raised if a command needs to print an error and exit."""
157 157
158 __bytes__ = _tobytes
158 def __init__(self, message, hint=None):
159 self.message = message
160 self.hint = hint
161 # Pass the message into the Exception constructor to help extensions
162 # that look for exc.args[0].
163 Exception.__init__(self, message)
164
165 def __bytes__(self):
166 return self.message
159 167
160 168 if pycompat.ispy3:
161 169
@@ -493,7 +493,7 b' class hgweb(object):'
493 493 except error.Abort as e:
494 494 res.status = b'403 Forbidden'
495 495 res.headers[b'Content-Type'] = ctype
496 return rctx.sendtemplate(b'error', error=pycompat.bytestr(e))
496 return rctx.sendtemplate(b'error', error=e.message)
497 497 except ErrorResponse as e:
498 498 for k, v in e.headers:
499 499 res.headers[k] = v
@@ -355,7 +355,10 b' def _donormalize(patterns, default, root'
355 355 except error.Abort as inst:
356 356 raise error.Abort(
357 357 b'%s: %s'
358 % (pat, inst[0]) # pytype: disable=unsupported-operands
358 % (
359 pat,
360 inst.message,
361 ) # pytype: disable=unsupported-operands
359 362 )
360 363 except IOError as inst:
361 364 if warn:
@@ -216,7 +216,7 b' def callcatch(ui, func):'
216 216 except error.WdirUnsupported:
217 217 ui.error(_(b"abort: working directory revision cannot be specified\n"))
218 218 except error.Abort as inst:
219 ui.error(_(b"abort: %s\n") % inst)
219 ui.error(_(b"abort: %s\n") % inst.message)
220 220 if inst.hint:
221 221 ui.error(_(b"(%s)\n") % inst.hint)
222 222 except ImportError as inst:
@@ -39,7 +39,6 b' from .utils import ('
39 39 dateutil,
40 40 hashutil,
41 41 procutil,
42 stringutil,
43 42 )
44 43
45 44 hg = None
@@ -84,9 +83,7 b' def annotatesubrepoerror(func):'
84 83 except error.Abort as ex:
85 84 subrepo = subrelpath(self)
86 85 errormsg = (
87 stringutil.forcebytestr(ex)
88 + b' '
89 + _(b'(in subrepository "%s")') % subrepo
86 ex.message + b' ' + _(b'(in subrepository "%s")') % subrepo
90 87 )
91 88 # avoid handling this exception by raising a SubrepoAbort exception
92 89 raise SubrepoAbort(
@@ -497,11 +497,11 b' def getbundle(repo, proto, others):'
497 497 # cleanly forward Abort error to the client
498 498 if not exchange.bundle2requested(opts.get(b'bundlecaps')):
499 499 if proto.name == b'http-v1':
500 return wireprototypes.ooberror(pycompat.bytestr(exc) + b'\n')
500 return wireprototypes.ooberror(exc.message + b'\n')
501 501 raise # cannot do better for bundle1 + ssh
502 502 # bundle2 request expect a bundle2 reply
503 503 bundler = bundle2.bundle20(repo.ui)
504 manargs = [(b'message', pycompat.bytestr(exc))]
504 manargs = [(b'message', exc.message)]
505 505 advargs = []
506 506 if exc.hint is not None:
507 507 advargs.append((b'hint', exc.hint))
@@ -684,7 +684,7 b' def unbundle(repo, proto, heads):'
684 684 # We did not change it to minimise code change.
685 685 # This need to be moved to something proper.
686 686 # Feel free to do it.
687 procutil.stderr.write(b"abort: %s\n" % exc)
687 procutil.stderr.write(b"abort: %s\n" % exc.message)
688 688 if exc.hint is not None:
689 689 procutil.stderr.write(b"(%s)\n" % exc.hint)
690 690 procutil.stderr.flush()
@@ -733,7 +733,7 b' def unbundle(repo, proto, heads):'
733 733 if exc.params:
734 734 errpart.addparam(b'params', b'\0'.join(exc.params))
735 735 except error.Abort as exc:
736 manargs = [(b'message', stringutil.forcebytestr(exc))]
736 manargs = [(b'message', exc.message)]
737 737 advargs = []
738 738 if exc.hint is not None:
739 739 advargs.append((b'hint', exc.hint))
@@ -52,7 +52,7 b' def debugbruterebase(ui, repo, source, d'
52 52 try:
53 53 rebase.rebase(ui, repo, dest=dest, rev=[spec])
54 54 except error.Abort as ex:
55 summary = b'ABORT: %s' % ex
55 summary = b'ABORT: %s' % ex.message
56 56 except Exception as ex:
57 57 summary = b'CRASH: %s' % ex
58 58 else:
@@ -392,7 +392,7 b' def test_url():'
392 392 >>> try:
393 393 ... u = url(b'file://mercurial-scm.org/foo')
394 394 ... except error.Abort as e:
395 ... forcebytestr(e)
395 ... e.message
396 396 'file:// URLs can only refer to localhost'
397 397
398 398 Empty URL:
General Comments 0
You need to be logged in to leave comments. Login now