From patchwork Mon Oct 14 06:39:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D7082: fix: fix registration of config item defaults From: phabricator X-Patchwork-Id: 42311 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Mon, 14 Oct 2019 06:39:48 +0000 martinvonz created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY Before this patch, because of the "(:)?", all registered patterns would match and the default value would not be the one we thought we had registered (maybe it just took the default value for the first match?). This didn't matter because we didn't care about the default value; we used our own, intended default value in getfixers() anyway. We also have to look up each config item individually in order to not get developer warnings. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D7082 AFFECTED FILES hgext/fix.py CHANGE DETAILS To: martinvonz, #hg-reviewers Cc: mercurial-devel diff --git a/hgext/fix.py b/hgext/fix.py --- a/hgext/fix.py +++ b/hgext/fix.py @@ -178,7 +178,7 @@ } for key, default in FIXER_ATTRS.items(): - configitem(b'fix', b'.*(:%s)?' % key, default=default, generic=True) + configitem(b'fix', b'.*:%s$' % key, default=default, generic=True) # A good default size allows most source code files to be fixed, but avoids # letting fixer tools choke on huge inputs, which could be surprising to the @@ -794,12 +794,11 @@ fixers = {} for name in fixernames(ui): fixers[name] = Fixer() - attrs = ui.configsuboptions(b'fix', name)[1] for key, default in FIXER_ATTRS.items(): setattr( fixers[name], pycompat.sysstr(b'_' + key), - attrs.get(key, default), + ui.config(b'fix', name + b':' + key, default), ) fixers[name]._priority = int(fixers[name]._priority) fixers[name]._metadata = stringutil.parsebool(fixers[name]._metadata)