comparison mercurial/ui.py @ 32446:420e93b0d9dc

ui: add the possiblity to get a date config field Add the method configdate to read a date from configuration. It uses the util.rawparsedate refactored earlier to support all standard date formats.
author Boris Feld <boris.feld@octobus.net>
date Fri, 19 May 2017 12:07:41 +0200
parents 2384a6546927
children 0ed730f3301c
comparison
equal deleted inserted replaced
32445:a7dce526c462 32446:420e93b0d9dc
596 if isinstance(default, bytes): 596 if isinstance(default, bytes):
597 default = config.parselist(default) 597 default = config.parselist(default)
598 return self.configwith(config.parselist, section, name, default or [], 598 return self.configwith(config.parselist, section, name, default or [],
599 'list', untrusted) 599 'list', untrusted)
600 600
601 def configdate(self, section, name, default=None, untrusted=False):
602 """parse a configuration element as a tuple of ints
603
604 >>> u = ui(); s = 'foo'
605 >>> u.setconfig(s, 'date', '0 0')
606 >>> u.configdate(s, 'date')
607 (0, 0)
608 """
609 if self.config(section, name, default, untrusted):
610 return self.configwith(util.parsedate, section, name, default,
611 'date', untrusted)
612 return default
613
601 def hasconfig(self, section, name, untrusted=False): 614 def hasconfig(self, section, name, untrusted=False):
602 return self._data(untrusted).hasitem(section, name) 615 return self._data(untrusted).hasitem(section, name)
603 616
604 def has_section(self, section, untrusted=False): 617 def has_section(self, section, untrusted=False):
605 '''tell whether section exists in config.''' 618 '''tell whether section exists in config.'''