# HG changeset patch
# User Matt Harbison <
matt_h...@yahoo.com>
# Date 1664388602 14400
# Wed Sep 28 14:10:02 2022 -0400
# Branch stable
# Node ID c4fca0a9077f8165565d5f87e7a0e3d9369978f6
# Parent b619f172c9da3520415adf9738d4ada63f7127f5
run: use format() to display error.Error style messages
The previous way lost useful information- specifically ConfigError wouldn't
display the corrupt file and line number. This is also how scmutil.callcatch()
handles it. See
https://foss.heptapod.net/mercurial/tortoisehg/thg/-/issues/5830.
The ConfigError case specifically needs the fix in qtlib.earlyBugReport(), but
might as well fix the other places errors are handled too.
diff --git a/tortoisehg/hgqt/qtapp.py b/tortoisehg/hgqt/qtapp.py
--- a/tortoisehg/hgqt/qtapp.py
+++ b/tortoisehg/hgqt/qtapp.py
@@ -112,6 +112,8 @@
'values': [hglib.tounicode(str(e))],
'error': traceback.format_exc(),
'nofork': True}
+ if isinstance(e, error.Error):
+ opts['error'] = hglib.tounicode(e.format())
if isinstance(e, error.ParseError) and e.location:
opts['values'] += [hglib.tounicode(e.location)]
errstring = _recoverableexc[e.__class__]
@@ -124,6 +126,8 @@
"""Show generic errors before the QApplication is started"""
opts = {'cmd': ' '.join(sys.argv[1:]),
'error': traceback.format_exc()}
+ if isinstance(e, error.Error):
+ opts['error'] = hglib.tounicode(e.format())
if not QApplication.instance():
main = QApplication(sys.argv)
dlg = bugreport.BugReport(opts)
diff --git a/tortoisehg/hgqt/run.py b/tortoisehg/hgqt/run.py
--- a/tortoisehg/hgqt/run.py
+++ b/tortoisehg/hgqt/run.py
@@ -363,9 +363,7 @@
except error.RepoError as inst:
ui.warn(_("abort: %s!\n") % inst)
except error.Abort as inst:
- ui.warn(_("abort: %s\n") % inst)
- if inst.hint:
- ui.warn(_("(%s)\n") % inst.hint)
+ ui.warn(inst.format())
return -1