diff mercurial/ui.py @ 31690:d83e51654c8a

rcutil: let environ override system configs (BC) This is BC because system configs won't be able to override $EDITOR, $PAGER. The new behavior is arguably more rational.
author Jun Wu <quark@fb.com>
date Sun, 26 Mar 2017 21:33:37 -0700
parents 00e569a2da97
children 5bea95a1d353
line wrap: on
line diff
--- a/mercurial/ui.py	Sun Mar 26 21:27:02 2017 -0700
+++ b/mercurial/ui.py	Sun Mar 26 21:33:37 2017 -0700
@@ -211,10 +211,20 @@
     def load(cls):
         """Create a ui and load global and user configs"""
         u = cls()
-        # we always trust global config files
+        # we always trust global config files and environment variables
         for t, f in rcutil.rccomponents():
             if t == 'path':
                 u.readconfig(f, trust=True)
+            elif t == 'items':
+                sections = set()
+                for section, name, value, source in f:
+                    # do not set u._ocfg
+                    # XXX clean this up once immutable config object is a thing
+                    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:
                 raise error.ProgrammingError('unknown rctype: %s' % t)
         return u