From 7b1eaddb8b2d5193db078785ca4730d287bb2809 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Sun, 5 Jan 2014 15:41:44 +0100 Subject: 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 ' would read '[subcommand]' as well as '[gbp-]' sections while 'gbp-' would only read '[gbp-]' sections. Closes: #733759 --- gbp/config.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'gbp/config.py') diff --git a/gbp/config.py b/gbp/config.py index 4952de4..f17d57f 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 syntax, so parse the old sections - # of {gbp.git}- 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): -- cgit v1.2.3