config: Don't pull in config defaults twice
authorGuido Günther <agx@sigxcpu.org>
Tue, 18 Feb 2014 21:54:41 +0000 (22:54 +0100)
committerGuido Günther <agx@sigxcpu.org>
Wed, 19 Feb 2014 07:33:33 +0000 (08:33 +0100)
This would otherwise overwrite values set in the legacy config sections.

Closes: #733759
gbp/config.py
tests/test_Config.py

index d4c0e5ad7a6a50aef09aad0f99a8939890489c5d..fa6e6798d074c25a289c82e06063d3591d62d196 100644 (file)
@@ -330,18 +330,19 @@ class GbpOptionParser(OptionParser):
             for prefix in ['gbp', 'git']:
                 oldcmd = '%s-%s' % (prefix, self.command)
                 if parser.has_section(oldcmd):
-                    # Don't use items() until we got rid of the compat sections
-                    # since this pulls in the defaults again
-                    self.config.update(dict(parser._sections[cmd].items()))
+                    self.config.update(dict(parser.items(oldcmd, raw=True)))
             cmd = self.command
 
         # Update with command specific settings
         if parser.has_section(cmd):
             self.config.update(dict(parser.items(cmd, raw=True)))
+            # Don't use items() until we got rid of the compat sections
+            # since this pulls in the defaults again
+            self.config.update(dict(parser._sections[cmd].items()))
 
         for section in self.sections:
             if parser.has_section(section):
-                self.config.update(dict(parser.items(section, raw=True)))
+                self.config.update(dict(parser._sections[section].items()))
             else:
                 raise NoSectionError("Mandatory section [%s] does not exist."
                                      % section)
index 9a68f8cccc249cb689e6a60afe6c79614b82fce3..2bae76539e6af573e72a42b3b4e582943edc0938 100644 (file)
@@ -72,7 +72,7 @@ def test_parser_fallback():
     >>> confname = os.path.join(tmpdir, 'gbp.conf')
     >>> parser.config_files = [confname]
     >>> f = open(confname, 'w')
-    >>> f.write('[foo]\\nthere = is\\n[git-foo]\\nno = truth\\n')
+    >>> f.write('[DEFAULT]\\nthere = was\\n[foo]\\nthere = is\\n[git-foo]\\nno = truth\\n')
     >>> f.close()
     >>> parser._parse_config_files()
     >>> parser.config['there']