Patchwork [01,of,23] web: use '_unset' default value for proxy config method

login
register
mail settings
Submitter Boris Feld
Date Sept. 16, 2017, 6:28 p.m.
Message ID <8f9210de17d825ec69c4.1505586488@FB>
Download mbox | patch
Permalink /patch/23953/
State Accepted
Headers show

Comments

Boris Feld - Sept. 16, 2017, 6:28 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1505496068 -7200
#      ven. sept. 15 19:21:08 2017 +0200
# Node ID 8f9210de17d825ec69c4cdb266398b941a088275
# Parent  709b44f38ab919c4f858f12807b9f01f6a2ee888
# EXP-Topic config.register.web
web: use '_unset' default value for proxy config method

This special value is needed to make sure registered default value are taken in
account.
Gregory Szorc - Sept. 16, 2017, 8:39 p.m.
On Sat, Sep 16, 2017 at 11:28 AM, Boris Feld <boris.feld@octobus.net> wrote:

> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1505496068 -7200
> #      ven. sept. 15 19:21:08 2017 +0200
> # Node ID 8f9210de17d825ec69c4cdb266398b941a088275
> # Parent  709b44f38ab919c4f858f12807b9f01f6a2ee888
> # EXP-Topic config.register.web
> web: use '_unset' default value for proxy config method
>

Queued this series, thanks.


>
> This special value is needed to make sure registered default value are
> taken in
> account.
>
> diff -r 709b44f38ab9 -r 8f9210de17d8 mercurial/hgweb/hgwebdir_mod.py
> --- a/mercurial/hgweb/hgwebdir_mod.py   mar. sept. 12 09:13:02 2017 -0700
> +++ b/mercurial/hgweb/hgwebdir_mod.py   ven. sept. 15 19:21:08 2017 +0200
> @@ -491,7 +491,7 @@
>              else:
>                  yield config('web', 'motd', '')
>
> -        def config(section, name, default=None, untrusted=True):
> +        def config(section, name, default=uimod._unset, untrusted=True):
>              return self.ui.config(section, name, default, untrusted)
>
>          self.updatereqenv(req.env)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
Augie Fackler - Sept. 16, 2017, 9:31 p.m.
> On Sep 16, 2017, at 2:28 PM, Boris Feld <boris.feld@octobus.net> wrote:
> 
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1505496068 -7200
> #      ven. sept. 15 19:21:08 2017 +0200
> # Node ID 8f9210de17d825ec69c4cdb266398b941a088275
> # Parent  709b44f38ab919c4f858f12807b9f01f6a2ee888
> # EXP-Topic config.register.web
> web: use '_unset' default value for proxy config method
> 
> This special value is needed to make sure registered default value are taken in
> account.
> 
> diff -r 709b44f38ab9 -r 8f9210de17d8 mercurial/hgweb/hgwebdir_mod.py
> --- a/mercurial/hgweb/hgwebdir_mod.py	mar. sept. 12 09:13:02 2017 -0700
> +++ b/mercurial/hgweb/hgwebdir_mod.py	ven. sept. 15 19:21:08 2017 +0200
> @@ -491,7 +491,7 @@
>             else:
>                 yield config('web', 'motd', '')
> 
> -        def config(section, name, default=None, untrusted=True):
> +        def config(section, name, default=uimod._unset, untrusted=True):

Using the _-prefixed unset singleton here is a hint that there’s some kind of layering violation here. it honestly looks like we could get rid of this entire proxy method.

(approving anyway, but a thought for future config-related cleanup.)

>             return self.ui.config(section, name, default, untrusted)
> 
>         self.updatereqenv(req.env)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff -r 709b44f38ab9 -r 8f9210de17d8 mercurial/hgweb/hgwebdir_mod.py
--- a/mercurial/hgweb/hgwebdir_mod.py	mar. sept. 12 09:13:02 2017 -0700
+++ b/mercurial/hgweb/hgwebdir_mod.py	ven. sept. 15 19:21:08 2017 +0200
@@ -491,7 +491,7 @@ 
             else:
                 yield config('web', 'motd', '')
 
-        def config(section, name, default=None, untrusted=True):
+        def config(section, name, default=uimod._unset, untrusted=True):
             return self.ui.config(section, name, default, untrusted)
 
         self.updatereqenv(req.env)