# HG changeset patch # User Yuya Nishihara # Date 1494744087 -32400 # Node ID 9c023179e8d03085c30d29a526046b0e73a4f112 # Parent 92de09a05d7f8dc3ace9023192c3562ddbdf75ad error: add hint to ProgrammingError As the hint isn't shown by the default exception handler, we need to print it manually. I've copied the "** " style from _exceptionwarning(). diff -r 92de09a05d7f -r 9c023179e8d0 mercurial/dispatch.py --- a/mercurial/dispatch.py Mon May 08 22:14:56 2017 +0900 +++ b/mercurial/dispatch.py Sun May 14 15:41:27 2017 +0900 @@ -162,6 +162,11 @@ ret = None try: ret = _runcatch(req) + except error.ProgrammingError as inst: + req.ui.warn(_('** ProgrammingError: %s\n') % inst) + if inst.hint: + req.ui.warn(_('** (%s)\n') % inst.hint) + raise except KeyboardInterrupt as inst: try: if isinstance(inst, error.SignalInterrupt): diff -r 92de09a05d7f -r 9c023179e8d0 mercurial/error.py --- a/mercurial/error.py Mon May 08 22:14:56 2017 +0900 +++ b/mercurial/error.py Sun May 14 15:41:27 2017 +0900 @@ -174,7 +174,7 @@ class PushRaced(RuntimeError): """An exception raised during unbundling that indicate a push race""" -class ProgrammingError(RuntimeError): +class ProgrammingError(Hint, RuntimeError): """Raised if a mercurial (core or extension) developer made a mistake""" # bundle2 related errors diff -r 92de09a05d7f -r 9c023179e8d0 tests/test-devel-warnings.t --- a/tests/test-devel-warnings.t Mon May 08 22:14:56 2017 +0900 +++ b/tests/test-devel-warnings.t Sun May 14 15:41:27 2017 +0900 @@ -3,7 +3,7 @@ > """A small extension that tests our developer warnings > """ > - > from mercurial import registrar, repair, util + > from mercurial import error, registrar, repair, util > > cmdtable = {} > command = registrar.command(cmdtable) @@ -61,6 +61,9 @@ > @command('nouiwarning', [], '') > def nouiwarning(ui, repo): > util.nouideprecwarn('this is a test', '13.37') + > @command('programmingerror', [], '') + > def programmingerror(ui, repo): + > raise error.ProgrammingError('something went wrong', hint='try again') > EOF $ cat << EOF >> $HGRCPATH @@ -163,9 +166,23 @@ ** Python * (glob) ** Mercurial Distributed SCM (*) (glob) ** Extensions loaded: * (glob) + ** ProgrammingError: transaction requires locking Traceback (most recent call last): mercurial.error.ProgrammingError: transaction requires locking + $ hg programmingerror 2>&1 | egrep -v '^ ' + ** Unknown exception encountered with possibly-broken third-party extension buggylocking + ** which supports versions unknown of Mercurial. + ** Please disable buggylocking and try your action again. + ** If that fixes the bug please report it to the extension author. + ** Python * (glob) + ** Mercurial Distributed SCM (*) (glob) + ** Extensions loaded: * (glob) + ** ProgrammingError: something went wrong + ** (try again) + Traceback (most recent call last): + mercurial.error.ProgrammingError: something went wrong + Old style deprecation warning $ hg nouiwarning