[PATCH 04 of 10 RFC v2] compat: module to handle different ui.compat settings
Jun Wu
quark at fb.com
Wed Mar 15 01:34:46 EDT 2017
Excerpts from David Soria Parra's message of 2017-03-12 15:40:27 -0700:
[...]
> +# compat.py - handlign compatibility settings
spell: "handling"
> +#
> +# Copyright 2005-2017 Mercurial Steering Committee
> +#
> +# This software may be used and distributed according to the terms of the
> +# GNU General Public License version 2 or any later version.
> +from __future__ import absolute_import
> +
> +import collections
> +from . import (
> + util,
> +)
> +
> +# The initialization msut be done with a list and not a dict, as a list
spell: "must"
> +# is sorted while a dictionary is not.
> +COMPAT = util.sortdict([
> + ('compat', {}),
> + ('latest', {})],
> +)
The format looks a bit inconsistent, maybe:
('latest', {}),
]),
> +
> +def modernize(ui):
> + compats = compatlevel(ui)
> + for section, d in compats.items():
> + for key, value in d.items():
> + ui._cfg['defaults'].set(section, key, value)
Maybe set source, so "hg config --debug" shows where the configs come from.
> +
> +def compatlevel(ui):
> + if ui.plain('compat'):
> + requested = 'compat'
> + else:
> + requested = ui.config('ui', 'compat', 'compat')
> +
> + result = {}
> + for level, configs in COMPAT.items():
> + result.update(configs)
> + if level == requested:
> + # defaults is sorted. We can abort once we reached
> + # the requested level.
> + break
> + return result
More information about the Mercurial-devel
mailing list