diff mercurial/configitems.py @ 33329:e714159860fd

configitems: add alias support in config Aliases define optional alternatives to existing options. For example the old option ui.user was deprecated and replaced by ui.username. With this mechanism, it's even possible to create an alias to an option in a different section. Add ui.user as alias to ui.username as an example of this concept. The old alternates principle in ui.config is removed as it was used only for this option.
author David Demelier <demelier.david@gmail.com>
date Fri, 07 Jul 2017 08:33:10 +0200
parents bbc57a7e8823
children d74141ccfd8b
line wrap: on
line diff
--- a/mercurial/configitems.py	Mon Jul 03 13:04:35 2017 +0200
+++ b/mercurial/configitems.py	Fri Jul 07 08:33:10 2017 +0200
@@ -32,12 +32,14 @@
     :section: the official config section where to find this item,
        :name: the official name within the section,
     :default: default value for this item,
+    :alias: optional list of tuples as alternatives.
     """
 
-    def __init__(self, section, name, default=None):
+    def __init__(self, section, name, default=None, alias=()):
         self.section = section
         self.name = name
         self.default = default
+        self.alias = list(alias)
 
 coreitems = {}
 
@@ -194,6 +196,9 @@
 coreconfigitem('ui', 'quiet',
     default=False,
 )
+coreconfigitem('ui', 'username',
+    alias=[('ui', 'user')]
+)
 # Windows defaults to a limit of 512 open files. A buffer of 128
 # should give us enough headway.
 coreconfigitem('worker', 'backgroundclosemaxqueue',