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

Augie Fackler raf at durin42.com
Tue Mar 21 18:28:33 EDT 2017


On Sat, Mar 18, 2017 at 06:06:47PM +0900, Yuya Nishihara wrote:
> 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.

Yeah, but it seems fine for that to clobber the system-default
ui.editor setting, since they're both controlled by the system
administrator.

>
> > --- 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.
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list