[PATCH] dispatch: allow suppression of the error message for a broken command

Martijn Pieters mj at zopatista.com
Wed Mar 23 17:27:58 EDT 2016


On 23 March 2016 at 14:09, Matt Mackall <mpm at selenic.com> wrote:
>> Add a configuration switch to simply not print the warning and re-raise.
>
> This description is maybe not precise enough. We have lots of different types of
> errors that we obviously don't want to supress. This looks like it's explicitly
> about tracebacks.

Right, this is about command failures, and both the warning message
and traceback are suppressed. As Pierre-Yves points out, this also
changes the exit code from 1 to 0 however, which was not my intention.

>
>> +        if (ui.configbool('ui', 'suppressfailures', False) and
>> +                issubclass(sys.exc_info()[0], Exception)):
>> +            # only suppress 'regular' non-system-exit exceptions
>> +            return
>>          ui.warn(warning)
>>          raise
>
> If this is only desirable with an extension, it might be better to just add a
> hook function into dispatch for this. Or even better: move everything from the
> last except: clause into a separate function that can be easily wrapped.

I like this idea; this'd let you fully customise how exceptions are
handled. I'll create a patch, superseding this one.

-- 
Martijn Pieters


More information about the Mercurial-devel mailing list