# HG changeset patch
# User Matt Harbison <
matt_h...@yahoo.com>
# Date 1658517491 14400
# Fri Jul 22 15:18:11 2022 -0400
# Branch stable
# Node ID b9c0b7bffdb6773f339068b1790039cf1b66c9f8
# Parent 65359680e4dbfd5e320d0de744f7f21fdb82f4dc
qtapp: fix a startup crash with an unparsable config file (fixes #5453)
It looks like this broke way back in dbc574601ef9. I didn't bother to look to
see where this used to be called, but as of now it is only called for a
`ParseError`, so it is way more elaborate than needed. I'm also not sure how it
used to get the second argument, because even iterating over the exception in
py2 only yielded the message as if cast to `str`. So since this is the only
exception passed, reach into the location field.
This may all be dead code. I tried injecting config file errors, and everything
got reported as a `ConfigError` with the normal crashreport dialog. I had to
manually raise a `ParseError` to ensure that the dialog with the option to fix
the config file is properly displayed.
diff --git a/tortoisehg/hgqt/qtapp.py b/tortoisehg/hgqt/qtapp.py
--- a/tortoisehg/hgqt/qtapp.py
+++ b/tortoisehg/hgqt/qtapp.py
@@ -107,9 +107,11 @@
}
def earlyExceptionMsgBox(e):
+ # type: (error.ParseError) -> None
"""Show message for recoverable error before the QApplication is started"""
opts = {'cmd': ' '.join(sys.argv[1:]),
- 'values': e,
+ 'values': [hglib.tounicode(str(e)),
+ hglib.tounicode(e.location) if e.location else u''],
'error': traceback.format_exc(),
'nofork': True}
errstring = _recoverableexc[e.__class__]
diff --git a/tortoisehg/hgqt/run.py b/tortoisehg/hgqt/run.py
--- a/tortoisehg/hgqt/run.py
+++ b/tortoisehg/hgqt/run.py
@@ -138,7 +138,7 @@
pdb.set_trace()
return _runcatch(u, args)
except error.ParseError as e:
- qtapp.earlyExceptionMsgBox(hglib.tounicode(str(e)))
+ qtapp.earlyExceptionMsgBox(e)
except SystemExit as e:
return e.code
except Exception as e: