mercurial/configitems.py
changeset 33002 6d983e8af49c
parent 33001 0d757af1ea67
child 33004 2529e2ae9f4c
--- a/mercurial/configitems.py	Sat Jun 17 18:41:55 2017 +0200
+++ b/mercurial/configitems.py	Sat Jun 17 18:43:27 2017 +0200
@@ -7,6 +7,10 @@
 
 from __future__ import absolute_import
 
+from . import (
+    error,
+)
+
 class configitem(object):
     """represent a known config item
 
@@ -19,3 +23,13 @@
         self.section = section
         self.name = name
         self.default = default
+
+coreitems = {}
+
+def coreconfigitem(*args, **kwargs):
+    item = configitem(*args, **kwargs)
+    section = coreitems.setdefault(item.section, {})
+    if item.name in section:
+        msg = "duplicated config item registration for '%s.%s'"
+        raise error.ProgrammingError(msg % (item.section, item.name))
+    section[item.name] = item