Patchwork D7933: config: add a function to insert non-file based, but overridable settings

login
register
mail settings
Submitter phabricator
Date Jan. 21, 2020, 4:26 p.m.
Message ID <3bc73a6bdd39baa2b73e1512c8a9c70d@localhost.localdomain>
Download mbox | patch
Permalink /patch/44548/
State Not Applicable
Headers show

Comments

phabricator - Jan. 21, 2020, 4:26 p.m.
Closed by commit rHGe2278581b1c6: config: add a function to insert non-file based, but overridable settings (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7933?vs=19437&id=19484

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7933/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7933

AFFECTED FILES
  mercurial/ui.py

CHANGE DETAILS




To: mharbison72, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -467,6 +467,25 @@ 
                     raise
                 self.warn(_(b'ignored: %s\n') % stringutil.forcebytestr(inst))
 
+        self._applyconfig(cfg, trusted, root)
+
+    def applyconfig(self, configitems, source=b"", root=None):
+        """Add configitems from a non-file source.  Unlike with ``setconfig()``,
+        they can be overridden by subsequent config file reads.  The items are
+        in the same format as ``configoverride()``, namely a dict of the
+        following structures: {(section, name) : value}
+
+        Typically this is used by extensions that inject themselves into the
+        config file load procedure by monkeypatching ``localrepo.loadhgrc()``.
+        """
+        cfg = config.config()
+
+        for (section, name), value in configitems.items():
+            cfg.set(section, name, value, source)
+
+        self._applyconfig(cfg, True, root)
+
+    def _applyconfig(self, cfg, trusted, root):
         if self.plain():
             for k in (
                 b'debug',