D7933: config: add a function to insert non-file based, but overridable settings
mharbison72 (Matt Harbison)
phabricator at mercurial-scm.org
Tue Jan 21 11:26:55 EST 2020
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
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',
To: mharbison72, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list