summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2014-01-05 15:41:44 +0100
committerGuido Günther <agx@sigxcpu.org>2014-01-05 15:41:44 +0100
commit7b1eaddb8b2d5193db078785ca4730d287bb2809 (patch)
tree41382f85854d483c5bb5ae2b35bd26dccb15368c
parent7c64575a685edaa4962c811d9d9321a615e7d22a (diff)
Make parsing config file sections symmetric
Always read the legacy command's config file section prior to the subcommand's config file section. Until now 'gbp <subcommand>' would read '[subcommand]' as well as '[gbp-<subcommand>]' sections while 'gbp-<subcommand>' would only read '[gbp-<subcommand>]' sections. Closes: #733759
-rw-r--r--gbp/config.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/gbp/config.py b/gbp/config.py
index 4952de4a..f17d57f4 100644
--- a/gbp/config.py
+++ b/gbp/config.py
@@ -318,18 +318,24 @@ class GbpOptionParser(OptionParser):
parser.read(self.config_files)
self.config.update(dict(parser.defaults()))
- if not (self.command.startswith('gbp-') or
- self.command.startswith('git-')):
- # Invoked as gbp <command> syntax, so parse the old sections
- # of {gbp.git}-<command> for backward compatibility:
+ # Make sure we read any legacy sections prior to the real subcommands
+ # section i.e. read [gbp-pull] prior to [pull]
+ if (self.command.startswith('gbp-') or
+ self.command.startswith('git-')):
+ oldcmd = self.command
+ if parser.has_section(oldcmd):
+ self.config.update(dict(parser.items(oldcmd, raw=True)))
+ cmd = self.command[4:]
+ else:
for prefix in ['gbp', 'git']:
oldcmd = '%s-%s' % (prefix, self.command)
if parser.has_section(oldcmd):
self.config.update(dict(parser.items(oldcmd, raw=True)))
+ cmd = self.command
# Update with command specific settings
- if parser.has_section(self.command):
- self.config.update(dict(parser.items(self.command, raw=True)))
+ if parser.has_section(cmd):
+ self.config.update(dict(parser.items(cmd, raw=True)))
for section in self.sections:
if parser.has_section(section):