[PATCH 06 of 10] ui: use scmutil.rccomponents to load configs (BC)

Yuya Nishihara yuya at tcha.org
Sat Mar 18 05:06:47 EDT 2017


On Mon, 13 Mar 2017 20:44:51 -0700, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1489462886 25200
> #      Mon Mar 13 20:41:26 2017 -0700
> # Node ID 685e4b92293443041840afc47a2445290c63f13b
> # Parent  c00819f7c5c38b6e8b3fa6c29578dd7d2592a59e
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r 685e4b922934
> ui: use scmutil.rccomponents to load configs (BC)
> 
> This is BC because system configs won't be able to override $EDITOR, $PAGER.
> The new behavior is arguably more rational.

The idea seems generally good to me, though $EDITOR may be set by the system
/etc/profile.

> --- a/mercurial/ui.py
> +++ b/mercurial/ui.py
> @@ -212,6 +212,18 @@ class ui(object):
>          u = cls()
>          # we always trust global config files
> -        for f in scmutil.rcpath():
> -            u.readconfig(f, trust=True)
> +        for (t, f) in scmutil.rccomponents():
> +            if t == 'path':
> +                u.readconfig(f, trust=True)
> +            elif t == 'items':
> +                sections = set()
> +                for section, name, value, source in f:
> +                    # do not set ocfg
> +                    u._tcfg.set(section, name, value, source)
> +                    u._ucfg.set(section, name, value, source)
> +                    sections.add(section)
> +                for section in sections:
> +                    u.fixconfig(section=section)
> +            else:
> +                assert False, 'unexpected rccomponent'

Nit: we could use ProgrammingError here.


More information about the Mercurial-devel mailing list