Patchwork [07,of,10] config: use the new '_unset' value for 'configdate'

login
register
mail settings
Submitter Pierre-Yves David
Date June 18, 2017, 6:55 p.m.
Message ID <f3d6b4a73db3dc172b7a.1497812117@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/21486/
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 1497696885 -7200
#      Sat Jun 17 12:54:45 2017 +0200
# Node ID f3d6b4a73db3dc172b7ac2f30c84d4e509df22fe
# Parent  d088b10b758236bde21b123edad6eae1b8d3139c
# 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 f3d6b4a73db3
config: use the new '_unset' value for 'configdate'

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

The default value for date (None) is still enforced in this method if no other
default were passed.

Patch

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -611,7 +611,7 @@  class ui(object):
             return []
         return v
 
-    def configdate(self, section, name, default=None, untrusted=False):
+    def configdate(self, section, name, default=_unset, untrusted=False):
         """parse a configuration element as a tuple of ints
 
         >>> u = ui(); s = 'foo'
@@ -622,6 +622,8 @@  class ui(object):
         if self.config(section, name, default, untrusted):
             return self.configwith(util.parsedate, section, name, default,
                                    'date', untrusted)
+        if default is _unset:
+            return None
         return default
 
     def hasconfig(self, section, name, untrusted=False):