[PATCH 1 of 8] configitems: add a basic class to hold config item information

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed Jun 21 08:55:02 UTC 2017


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at octobus.net>
# Date 1497717715 -7200
#      Sat Jun 17 18:41:55 2017 +0200
# Node ID 76b9e5749847f4c80a9bbd70f1eede96cb41e4fe
# Parent  4107eb8a5648ad31f7fb3e95bbc8999c73a94c49
# 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 76b9e5749847
configitems: add a basic class to hold config item information

The goal of this class is allow explicit declaration for the available config
option. This class will hold the data for one specific config item.

To keep it simple we start centralizing the handling of the default config value.

In the future we can expect more data to be carried on this class. For example:
 - documentation,
 - status (experimental, advanced, normal, deprecated),
 - aliases,
 - expected type,
 - etc...

diff --git a/mercurial/configitems.py b/mercurial/configitems.py
new file mode 100644
--- /dev/null
+++ b/mercurial/configitems.py
@@ -0,0 +1,25 @@
+# config.py - centralized declaration of configuration option
+#
+#  Copyright 2017 Pierre-Yves David <pierre-yves.david at octobus.net>
+#
+# This software may be used and distributed according to the terms of the
+# GNU General Public License version 2 or any later version.
+
+from __future__ import absolute_import
+
+from . import (
+    error,
+)
+
+class configitem(object):
+    """represent a known config item
+
+    :section: the official config section where to find this item,
+       :name: the official name within the section,
+    :default: default value for this item,
+    """
+
+    def __init__(self, section, name, default=None):
+        self.section = section
+        self.name = name
+        self.default = default


More information about the Mercurial-devel mailing list