# HG changeset patch # User Bryan O'Sullivan # Date 2016-01-08 03:45:03 # Node ID e70c97cc9243c6ea0acc0cbcc77e173c651e559a # Parent fb0cc863d172044a978ff01d104cddbdc15eca1d 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. diff --git a/mercurial/config.py b/mercurial/config.py --- a/mercurial/config.py +++ b/mercurial/config.py @@ -30,6 +30,8 @@ class config(object): 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): diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -507,6 +507,9 @@ class ui(object): 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)