Mercurial > hg
changeset 27696:e70c97cc9243
config: add hasconfig method and supporting plumbing
We add the hasconfig method to make it possible to distinguish between a
config value that was never supplied and one that is empty.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Thu, 07 Jan 2016 19:45:03 -0800 |
parents | fb0cc863d172 |
children | 0ce0cfee497f |
files | mercurial/config.py mercurial/ui.py |
diffstat | 2 files changed, 5 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/config.py Tue Jan 05 21:25:51 2016 -0800 +++ b/mercurial/config.py Thu Jan 07 19:45:03 2016 -0800 @@ -30,6 +30,8 @@ return config(self) def __contains__(self, section): return section in self._data + def hasitem(self, section, item): + return item in self._data.get(section, {}) def __getitem__(self, section): return self._data.get(section, {}) def __iter__(self):
--- a/mercurial/ui.py Tue Jan 05 21:25:51 2016 -0800 +++ b/mercurial/ui.py Thu Jan 07 19:45:03 2016 -0800 @@ -507,6 +507,9 @@ result = default or [] return result + def hasconfig(self, section, name, untrusted=False): + return self._data(untrusted).hasitem(section, name) + def has_section(self, section, untrusted=False): '''tell whether section exists in config.''' return section in self._data(untrusted)