[PATCH RFC] ui: add support for a tweakdefaults knob
Yuya Nishihara
yuya at tcha.org
Fri Jun 16 15:14:22 UTC 2017
On Wed, 14 Jun 2017 21:37:21 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie at google.com>
> # Date 1497488194 14400
> # Wed Jun 14 20:56:34 2017 -0400
> # Node ID 0e5ea7a86a8021d02218c35b07366ac6081ab3fb
> # Parent 3abba5bc34546951b11b1bd3f5e5c77b90d950d1
> ui: add support for a tweakdefaults knob
Queued this, thanks.
> @@ -241,8 +257,29 @@ class ui(object):
> u.fixconfig(section=section)
> else:
> raise error.ProgrammingError('unknown rctype: %s' % t)
> + u._maybetweakdefaults()
> return u
>
> + def _maybetweakdefaults(self):
> + if not self.configbool('ui', 'tweakdefaults'):
> + return
> + if self._tweaked or self.plain('tweakdefaults'):
> + return
tweakdefaults can't be disabled by --config if it's enabled by rc files.
Maybe this could be fixed by moving ui._maybetweakdefaults() to dispatch.py
where color.setup() is called.
> + # Note: it is SUPER IMPORTANT that you set self._tweaked to
> + # True *before* any calls to setconfig(), otherwise you'll get
> + # infinite recursion between setconfig and this method.
> + #
> + # TODO: We should extract an inner method in setconfig() to
> + # avoid this weirdness.
> + self._tweaked = True
> + tmpcfg = config.config()
> + tmpcfg.parse('<tweakdefaults>', tweakrc)
> + for section in tmpcfg:
> + for name, value in tmpcfg.items(section):
> + if not self.hasconfig(section, name):
> + self.setconfig(section, name, value, "<tweakdefaults>")
I have no idea how we should process values which are only set in untrusted
config. Using hasconfig(untrusted=True) might be a bit safer, but there would
still be inconsistency.
Another problem is self._ocfg can shadow repo config which isn't loaded yet
when _maybetweakdefaults() is called.
More information about the Mercurial-devel
mailing list