##// END OF EJS Templates
ui: add method to return option and all sub-options...
Gregory Szorc -
r27252:dccbebcf default
parent child Browse files
Show More
@@ -280,6 +280,39 b' class ui(object):'
280 "%s.%s = %s\n" % (section, n, uvalue))
280 "%s.%s = %s\n" % (section, n, uvalue))
281 return value
281 return value
282
282
283 def configsuboptions(self, section, name, default=None, untrusted=False):
284 """Get a config option and all sub-options.
285
286 Some config options have sub-options that are declared with the
287 format "key:opt = value". This method is used to return the main
288 option and all its declared sub-options.
289
290 Returns a 2-tuple of ``(option, sub-options)``, where `sub-options``
291 is a dict of defined sub-options where keys and values are strings.
292 """
293 data = self._data(untrusted)
294 main = data.get(section, name, default)
295 if self.debugflag and not untrusted and self._reportuntrusted:
296 uvalue = self._ucfg.get(section, name)
297 if uvalue is not None and uvalue != main:
298 self.debug('ignoring untrusted configuration option '
299 '%s.%s = %s\n' % (section, name, uvalue))
300
301 sub = {}
302 prefix = '%s:' % name
303 for k, v in data.items(section):
304 if k.startswith(prefix):
305 sub[k[len(prefix):]] = v
306
307 if self.debugflag and not untrusted and self._reportuntrusted:
308 for k, v in sub.items():
309 uvalue = self._ucfg.get(section, '%s:%s' % (name, k))
310 if uvalue is not None and uvalue != v:
311 self.debug('ignoring untrusted configuration option '
312 '%s:%s.%s = %s\n' % (section, name, k, uvalue))
313
314 return main, sub
315
283 def configpath(self, section, name, default=None, untrusted=False):
316 def configpath(self, section, name, default=None, untrusted=False):
284 'get a path config item, expanded relative to repo root or config file'
317 'get a path config item, expanded relative to repo root or config file'
285 v = self.config(section, name, default, untrusted)
318 v = self.config(section, name, default, untrusted)
General Comments 0
You need to be logged in to leave comments. Login now