rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
This can be used for reading many config options of various types where the
type of each is known in some other structure (e.g. options matching command
flags).
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D2622
AFFECTED FILES
mercurial/ui.py
CHANGE DETAILS
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -545,6 +545,16 @@
return main, sub
+def configtyped(self, section, name, itemtype, default=_unset,
untrusted=False):
+"""Get a config item as the given type."""
+if itemtype is type(False) or itemtype is type(None):
+return self.configbool(section, name, default, untrusted)
+if itemtype is type(1):
+return self.configint(section, name, default, untrusted)
+if itemtype is type([]):
+return self.configlist(section, name, default, untrusted)
+return self.config(section, name, default, untrusted)
+
def configpath(self, section, name, default=_unset, untrusted=False):
'get a path config item, expanded relative to repo root or config file'
v = self.config(section, name, default, untrusted)
To: rdamazio, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel