Patchwork [1,of,6] config: fix restoreconfig of non existing config

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 6, 2014, 4:27 a.m.
Message ID <a0abbd44e930bd673c08.1407299249@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5283/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 6, 2014, 4:27 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# 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.

Patch

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|)')