aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2013-06-26 18:43:49 +0200
committerGuido Günther <agx@sigxcpu.org>2013-06-26 20:37:52 +0200
commit38d43b4f0c292d28c511a9968008a500b8565768 (patch)
tree275f072440e5b6e5546f9c62ae360947d178cd18
parentff9f935462563819953115e53d0223c979388187 (diff)
config: Don't fill in the parser with all defaults
There's no need to fill the parser with all the built in defaults since we can simply copy them to the config from the class dict. This allows us to first set the values from the old {git,gbp}-* commands and then only overwrite changed values from the newer "gbp <command>" versions. Otherwise we'd overwite all old style config with the new style one. This also fixes the problem where the default section wouldn't be read at all if the command doesn't even have an empty section in any gbp.conf file.
-rw-r--r--gbp/config.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/gbp/config.py b/gbp/config.py
index fdf1647..84441b8 100644
--- a/gbp/config.py
+++ b/gbp/config.py
@@ -307,9 +307,13 @@ class GbpOptionParser(OptionParser):
Parse the possible config files and set appropriate values
default values
"""
- parser = SafeConfigParser(dict(self.__class__.defaults))
+ parser = SafeConfigParser()
+ # Fill in the built in values
+ self.config = dict(self.__class__.defaults)
+ # Update with the values from the defaults section. This is needed
+ # in case the config file doesn't have a [<command>] section at all
parser.read(self.config_files)
- self.config = dict(parser.defaults())
+ self.config.update(dict(parser.defaults()))
if not (self.command.startswith('gbp-') or
self.command.startswith('git-')):
@@ -320,6 +324,7 @@ class GbpOptionParser(OptionParser):
if parser.has_section(oldcmd):
self.config.update(dict(parser.items(oldcmd, raw=True)))
+ # Update with command specific settings
if parser.has_section(self.command):
self.config.update(dict(parser.items(self.command, raw=True)))