[PATCH STABLE] configitems: relax warning about unwanted default value

Augie Fackler raf at durin42.com
Wed Nov 1 10:55:26 EDT 2017


> On Oct 31, 2017, at 11:30, Yuya Nishihara <yuya at tcha.org> wrote:
> 
> On Tue, 31 Oct 2017 10:44:42 -0400, Augie Fackler wrote:
>>> On Oct 31, 2017, at 10:32, Yuya Nishihara <yuya at tcha.org> wrote:
>>> # HG changeset patch
>>> # User Yuya Nishihara <yuya at tcha.org>
>>> # Date 1509457050 -32400
>>> #      Tue Oct 31 22:37:30 2017 +0900
>>> # Branch stable
>>> # Node ID 4f00958f5fc9d7ae90468f6159dff7720d0f2b27
>>> # Parent  5caae380ff90735b1a1841a4f26147bf0f01351b
>>> configitems: relax warning about unwanted default value
>>> 
>>> The original condition was a bit harsh for extension authors since third-party
>>> extensions need to preserve compatibility with older Mercurial versions, where
>>> no defaults would be loaded from the configtable. So let's silence the warning
>>> if the given default value matches, which should be harmless.
>>> 
>>> diff --git a/mercurial/ui.py b/mercurial/ui.py
>>> --- a/mercurial/ui.py
>>> +++ b/mercurial/ui.py
>>> @@ -471,12 +471,16 @@ class ui(object):
>>>        return value
>>> 
>>>    def _config(self, section, name, default=_unset, untrusted=False):
>>> -        value = default
>>> +        value = itemdefault = default
>>>        item = self._knownconfig.get(section, {}).get(name)
>>>        alternates = [(section, name)]
>>> 
>>>        if item is not None:
>>>            alternates.extend(item.alias)
>>> +            if callable(item.default):
>>> +                itemdefault = item.default()
>>> +            else:
>>> +                itemdefault = item.default
>>>        else:
>>>            msg = ("accessing unregistered config item: '%s.%s'")
>>>            msg %= (section, name)
>>> @@ -490,12 +494,11 @@ class ui(object):
>>>                msg = "config item requires an explicit default value: '%s.%s'"
>>>                msg %= (section, name)
>>>                self.develwarn(msg, 2, 'warn-config-default')
>>> -            elif callable(item.default):
>>> -                    value = item.default()
>>>            else:
>>> -                value = item.default
>>> +                value = itemdefault
>>>        elif (item is not None
>>> -              and item.default is not configitems.dynamicdefault):
>>> +              and item.default is not configitems.dynamicdefault
>>> +              and default != itemdefault):
>>>            msg = ("specifying a default value for a registered "
>>>                   "config item: '%s.%s' '%s'")
>> 
>> nit: should I edit the message to say "mismatched default" since that's what we're really complaining about?
> 
> I don't care much about that, but "specifying a mismatched default" sounds
> more correct. Can you update it in flight?

Queued with that fixed in flight, many thanks.


More information about the Mercurial-devel mailing list