Patchwork [06,of,10] config: use the new '_unset' value for 'configlist'

login
register
mail settings
Submitter Pierre-Yves David
Date June 18, 2017, 6:55 p.m.
Message ID <d088b10b758236bde21b.1497812116@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/21485/
State Accepted
Headers show

Comments

Pierre-Yves David - June 18, 2017, 6:55 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1497696844 -7200
#      Sat Jun 17 12:54:04 2017 +0200
# Node ID d088b10b758236bde21b123edad6eae1b8d3139c
# Parent  fa4f7a297bc32124742d631460fa44677854f202
# EXP-Topic config.register
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r d088b10b7582
config: use the new '_unset' value for 'configlist'

This should let 'configlist' delegate all special processing of the default
config value to the main 'config' method.

The default config value ([]) is still handled in this method.

Patch

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -593,7 +593,7 @@  class ui(object):
             raise error.ConfigError(_("%s.%s is not a byte quantity ('%s')")
                                     % (section, name, value))
 
-    def configlist(self, section, name, default=None, untrusted=False):
+    def configlist(self, section, name, default=_unset, untrusted=False):
         """parse a configuration element as a list of comma/space separated
         strings
 
@@ -603,10 +603,13 @@  class ui(object):
         ['this', 'is', 'a small', 'test']
         """
         # default is not always a list
-        if isinstance(default, bytes):
-            default = config.parselist(default)
-        return self.configwith(config.parselist, section, name, default or [],
+        v = self.configwith(config.parselist, section, name, default,
                                'list', untrusted)
+        if isinstance(v, bytes):
+            return config.parselist(v)
+        elif v is None:
+            return []
+        return v
 
     def configdate(self, section, name, default=None, untrusted=False):
         """parse a configuration element as a tuple of ints