Patchwork [1,of,2] hgweb: forward arguments to ui.config

login
register
mail settings
Submitter David Demelier
Date July 3, 2017, 1:55 p.m.
Message ID <2d7f5d2ab80c85251bae.1499090146@fedy>
Download mbox | patch
Permalink /patch/21955/
State Changes Requested
Headers show

Comments

David Demelier - July 3, 2017, 1:55 p.m.
# HG changeset patch
# User David Demelier <demelier.david@gmail.com>
# Date 1498646251 -7200
#      Wed Jun 28 12:37:31 2017 +0200
# Node ID 2d7f5d2ab80c85251baea4fb49c13aac64f07763
# Parent  4d780d510b44ad2ae3bb39f3816c95598704d1eb
hgweb: forward arguments to ui.config
Yuya Nishihara - July 4, 2017, 1:34 p.m.
On Mon, 03 Jul 2017 15:55:46 +0200, David Demelier wrote:
> # HG changeset patch
> # User David Demelier <demelier.david@gmail.com>
> # Date 1498646251 -7200
> #      Wed Jun 28 12:37:31 2017 +0200
> # Node ID 2d7f5d2ab80c85251baea4fb49c13aac64f07763
> # Parent  4d780d510b44ad2ae3bb39f3816c95598704d1eb
> hgweb: forward arguments to ui.config
> 
> diff -r 4d780d510b44 -r 2d7f5d2ab80c mercurial/hgweb/hgweb_mod.py
> --- a/mercurial/hgweb/hgweb_mod.py	Tue Jun 27 00:01:17 2017 -0700
> +++ b/mercurial/hgweb/hgweb_mod.py	Wed Jun 28 12:37:31 2017 +0200
> @@ -119,21 +119,21 @@
>          self.csp, self.nonce = cspvalues(self.repo.ui)
>  
>      # Trust the settings from the .hg/hgrc files by default.
> -    def config(self, section, name, default=None, untrusted=True):
> -        return self.repo.ui.config(section, name, default,
> -                                   untrusted=untrusted)
> +    def config(self, *args, **kwargs):
> +        kwargs.setdefault('untrusted', True)
> +        return self.repo.ui.config(*args, **kwargs)

What if untrusted is passed as a positional argument?

Patch

diff -r 4d780d510b44 -r 2d7f5d2ab80c mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py	Tue Jun 27 00:01:17 2017 -0700
+++ b/mercurial/hgweb/hgweb_mod.py	Wed Jun 28 12:37:31 2017 +0200
@@ -119,21 +119,21 @@ 
         self.csp, self.nonce = cspvalues(self.repo.ui)
 
     # Trust the settings from the .hg/hgrc files by default.
-    def config(self, section, name, default=None, untrusted=True):
-        return self.repo.ui.config(section, name, default,
-                                   untrusted=untrusted)
+    def config(self, *args, **kwargs):
+        kwargs.setdefault('untrusted', True)
+        return self.repo.ui.config(*args, **kwargs)
 
-    def configbool(self, section, name, default=False, untrusted=True):
-        return self.repo.ui.configbool(section, name, default,
-                                       untrusted=untrusted)
+    def configbool(self, *args, **kwargs):
+        kwargs.setdefault('untrusted', True)
+        return self.repo.ui.configbool(*args, **kwargs)
 
-    def configint(self, section, name, default=None, untrusted=True):
-        return self.repo.ui.configint(section, name, default,
-                                      untrusted=untrusted)
+    def configint(self, *args, **kwargs):
+        kwargs.setdefault('untrusted', True)
+        return self.repo.ui.configint(*args, **kwargs)
 
-    def configlist(self, section, name, default=None, untrusted=True):
-        return self.repo.ui.configlist(section, name, default,
-                                       untrusted=untrusted)
+    def configlist(self, *args, **kwargs):
+        kwargs.setdefault('untrusted', True)
+        return self.repo.ui.configlist(*args, **kwargs)
 
     def archivelist(self, nodeid):
         allowed = self.configlist('web', 'allow_archive')
diff -r 4d780d510b44 -r 2d7f5d2ab80c mercurial/hgweb/hgwebdir_mod.py
--- a/mercurial/hgweb/hgwebdir_mod.py	Tue Jun 27 00:01:17 2017 -0700
+++ b/mercurial/hgweb/hgwebdir_mod.py	Wed Jun 28 12:37:31 2017 +0200
@@ -404,9 +404,9 @@ 
                 except Exception as e:
                     u.warn(_('error reading %s/.hg/hgrc: %s\n') % (path, e))
                     continue
-                def get(section, name, default=None):
-                    return u.config(section, name, default, untrusted=True)
-
+                def get(*args, **kwargs):
+                    kwargs.setdefault('untrusted', True)
+                    return u.config(*args, **kwargs)
                 if u.configbool("web", "hidden", untrusted=True):
                     continue