From patchwork Wed Aug 6 04:27:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1,of,6] config: fix restoreconfig of non existing config From: Pierre-Yves David X-Patchwork-Id: 5283 Message-Id: To: mercurial-devel@selenic.com Cc: pierre-yves.david@ens-lyon.org Date: Tue, 05 Aug 2014 21:27:29 -0700 # HG changeset patch # User Pierre-Yves David # Date 1407298584 25200 # Tue Aug 05 21:16:24 2014 -0700 # Node ID a0abbd44e930bd673c088f8412c46efc1d0b442a # Parent c6e1f2c6d5f19538869338fa50ad519be6eb9b24 config: fix restoreconfig of non existing config When the section, but no value existed, the `del` call raised a key error. diff --git a/mercurial/config.py b/mercurial/config.py --- a/mercurial/config.py +++ b/mercurial/config.py @@ -74,11 +74,11 @@ class config(object): self._source[(section, item)] = source else: # no data before, remove everything section, item = data if section in self._data: - del self._data[section][item] + self._data[section].pop(item, None) self._source.pop((section, item), None) def parse(self, src, data, sections=None, remap=None, include=None): sectionre = util.re.compile(r'\[([^\[]+)\]') itemre = util.re.compile(r'([^=\s][^=]*?)\s*=\s*(.*\S|)')