[PATCH 2 of 2] extensions: catch uisetup and extsetup failures and don't let them break hg

Augie Fackler raf at durin42.com
Tue Jun 6 10:57:04 EDT 2017


> On Jun 6, 2017, at 10:36, Martin von Zweigbergk via Mercurial-devel <mercurial-devel at mercurial-scm.org> wrote:
> 
> 
>> 
>> On Jun 6, 2017 7:15 AM, "Augie Fackler" <raf at durin42.com> wrote:
>> # HG changeset patch
>> # User Augie Fackler <augie at google.com>
>> # Date 1496758188 14400
>> #      Tue Jun 06 10:09:48 2017 -0400
>> # Node ID 9681ff165ea757e99bbb355412708f8d45f922c1
>> # Parent  656e5d8cab2048029eb16b7096bd44f9abe5bf7b
>> extensions: catch uisetup and extsetup failures and don't let them break hg
>> 
>> Otherwise users of the patience diff extension will be unable to run
>> anything at all in hg 4.3 until they figure out what's broken.
>> 
>> diff --git a/mercurial/extensions.py b/mercurial/extensions.py
>> --- a/mercurial/extensions.py
>> +++ b/mercurial/extensions.py
>> @@ -167,17 +167,25 @@ def load(ui, name, path):
>>  def _runuisetup(name, ui):
>>      uisetup = getattr(_extensions[name], 'uisetup', None)
>>      if uisetup:
>> -        uisetup(ui)
>> +        try:
>> +            uisetup(ui)
>> +        except Exception as inst:
>> +            msg = _forbytes(inst)
>> +            ui.warn(_("*** failed to set up extension %s: %s\n") % (name, msg))
>> 
> Maybe we should re-raise so the extension doesn't end up half loaded?

Maybe, but I'd rather try it this way in the hopes that it helps users by at least letting them run 'debuginstall' or similar without having to tweak their config.


More information about the Mercurial-devel mailing list