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