diff mercurial/ui.py @ 33471:d74141ccfd8b

configitems: handle case were the default value is not static In some case, the default of one value is derived from other value. We add a way to register them anyway and an associated devel-warning. The registration is very naive for the moment. We might be able to have a better way for registering each of these cases but it could be done later.
author Boris Feld <boris.feld@octobus.net>
date Wed, 12 Jul 2017 23:36:10 +0200
parents e714159860fd
children 0407a51b9d8c
line wrap: on
line diff
--- a/mercurial/ui.py	Fri Jul 14 16:17:37 2017 +0200
+++ b/mercurial/ui.py	Wed Jul 12 23:36:10 2017 +0200
@@ -457,11 +457,17 @@
         if default is _unset:
             if item is None:
                 value = default
+            elif item.default is configitems.dynamicdefault:
+                value = None
+                msg = "config item requires an explicit default value: '%s.%s'"
+                msg %= (section, name)
+                self.develwarn(msg, 2, 'warn-config-default')
             elif callable(item.default):
                     value = item.default()
             else:
                 value = item.default
-        elif item is not None:
+        elif (item is not None
+              and item.default is not configitems.dynamicdefault):
             msg = ("specifying a default value for a registered "
                    "config item: '%s.%s' '%s'")
             msg %= (section, name, default)