[PATCH RFC] ui: add support for a tweakdefaults knob
Augie Fackler
raf at durin42.com
Thu Jun 15 11:21:33 EDT 2017
> On Jun 15, 2017, at 11:19, Yuya Nishihara <yuya at tcha.org> wrote:
>
> 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
>
> +1
>
>> + def _maybetweakdefaults(self):
>> + if not self.configbool('ui', 'tweakdefaults'):
>> + return
>> + if self._tweaked or self.plain('tweakdefaults'):
>> + return
>> +
>> + # 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>")
>
> Maybe we want tmpcfg -> {ucfg, tcfg} -> ocfg layers, but it wouldn't be
> doable right now since tmpcfg should be inserted *after* [uto]cfg are
> loaded.
Yeah. Nobody seems motivated enough to do that work, which I totally get, so I did "done" instead of "clean". If it ever gets to be enough of a pain we can refactor, and we can maybe fix it up if we ever redo configuration to be a stack of immutable objects.
More information about the Mercurial-devel
mailing list