[PATCH 3 of 6 V2] ui: add hasconfig method to check if a config item is set

mathias.demare at gmail.com mathias.demare at gmail.com
Tue Apr 7 14:00:49 CDT 2015


# HG changeset patch
# User Mathias De Maré <mathias.demare at gmail.com>
# Date 1428348883 -7200
#      Mon Apr 06 21:34:43 2015 +0200
# Node ID 29f1d521db03dea5d14aa4d3cbd6705e038849d5
# Parent  411bfd6b77b418249d42817816b3a2526863b0b0
ui: add hasconfig method to check if a config item is set

diff -r 411bfd6b77b4 -r 29f1d521db03 mercurial/ui.py
--- a/mercurial/ui.py	Mon Apr 06 21:32:27 2015 +0200
+++ b/mercurial/ui.py	Mon Apr 06 21:34:43 2015 +0200
@@ -456,6 +456,11 @@
         '''tell whether section exists in config.'''
         return section in self._data(untrusted)
 
+    def hasconfig(self, section, config, untrusted=False):
+        '''tell whether config item exists in config.'''
+        return self.has_section(section, untrusted) \
+                    and config in self._data(untrusted)[section]
+
     def configitems(self, section, untrusted=False):
         items = self._data(untrusted).items(section)
         if self.debugflag and not untrusted and self._reportuntrusted:


More information about the Mercurial-devel mailing list