[PATCH 2 of 2 v2] hgweb: forward arguments to ui.config

Yuya Nishihara yuya at tcha.org
Sat Jul 1 23:13:39 EDT 2017


On Sat, 1 Jul 2017 17:13:22 +0200, Pierre-Yves David wrote:
> On 07/01/2017 06:03 AM, demelier.david at gmail.com wrote:
> > On Thu, 2017-06-29 at 21:42 -0700, Jun Wu wrote:
> >> I might miss something, but why is this change necessary? I slightly
> >> prefer
> >> the old code where arguments are more explicit, and people can
> >> override
> >> untrusted to False.
> > 
> > The problem is that def.config uses a local _unset variable for the
> > default argument.
> > 
> > The hgweb_mod.py uses None so you get a warning while running the tests
> > because of this code:
> > 
> >   463             msg = ("specifying a default value for a registered "
> >   464                    "config item: '%s.%s' '%s'")
> > 
> > An other solution woudl be to rename _unset to unset and export it so
> > that hgweb_mod.py can pass unset instead of None by default.
> > 
> > What do you think?
> 
> The issue with your patch is that is change the behavior from
> 
>   * untrusted default to False but another value can be passed
> 
> to
> 
>   * untrusted is always True.
> 
> You can easily fixes it by avoiding overwriting the untrusted value if 
> it is passed.
> 
> The extended version of the code would be:
> 
>    if 'untrusted' not in kwargs:
>        kwargs['untrusted'] = True
> 
> A short version would be:
> 
>    kwargs.setdefault('untrusted', True)

Perhaps we can just use uimod._unset until default= arguments are removed
from these functions. I generally prefer explicit list of arguments than
*args, **kwargs.


More information about the Mercurial-devel mailing list