Mercurial > hg-stable
changeset 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 | a7dce526c462 |
children | 3e2e179ef031 |
files | mercurial/ui.py |
diffstat | 1 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/ui.py Fri May 19 12:07:23 2017 +0200 +++ b/mercurial/ui.py Fri May 19 12:07:41 2017 +0200 @@ -598,6 +598,19 @@ return self.configwith(config.parselist, section, name, default or [], 'list', untrusted) + def configdate(self, section, name, default=None, untrusted=False): + """parse a configuration element as a tuple of ints + + >>> u = ui(); s = 'foo' + >>> u.setconfig(s, 'date', '0 0') + >>> u.configdate(s, 'date') + (0, 0) + """ + if self.config(section, name, default, untrusted): + return self.configwith(util.parsedate, section, name, default, + 'date', untrusted) + return default + def hasconfig(self, section, name, untrusted=False): return self._data(untrusted).hasitem(section, name)