config: move "component display" in the new module
That part seems dubious, but at least it is now isolated. I added inline comment
about how "suboptimal" it is.
--- a/mercurial/commands.py Mon Oct 21 14:05:14 2024 +0200
+++ b/mercurial/commands.py Mon Oct 21 14:13:37 2024 +0200
@@ -68,7 +68,6 @@
from .cmd_impls import graft as graft_impl
from .configuration import (
command as config_command,
- rcutil,
)
from .utils import (
dateutil,
@@ -2370,18 +2369,10 @@
edit_level = config_command.find_edit_level(ui, repo, opts)
if edit_level is not None:
return config_command.edit_config(ui, repo, edit_level)
+
ui.pager(b'config')
+ config_command.show_component(ui, repo)
fm = ui.formatter(b'config', pycompat.byteskwargs(opts))
- for t, f in rcutil.rccomponents():
- if t == b'path':
- ui.debug(b'read config from: %s\n' % f)
- elif t == b'resource':
- ui.debug(b'read config from: resource:%s.%s\n' % (f[0], f[1]))
- elif t == b'items':
- # Don't print anything for 'items'.
- pass
- else:
- raise error.ProgrammingError(b'unknown rctype: %s' % t)
untrusted = bool(opts.get('untrusted'))
selsections = selentries = []
--- a/mercurial/configuration/command.py Mon Oct 21 14:05:14 2024 +0200
+++ b/mercurial/configuration/command.py Mon Oct 21 14:13:37 2024 +0200
@@ -106,3 +106,21 @@
errprefix=_(b"edit failed"),
blockedtag=b'config_edit',
)
+
+
+def show_component(ui: uimod.ui, repo) -> None:
+ """show the component used to build the config
+
+ XXX this skip over various source and ignore the repository config, so it
+ XXX is probably useless old code.
+ """
+ for t, f in rcutil.rccomponents():
+ if t == b'path':
+ ui.debug(b'read config from: %s\n' % f)
+ elif t == b'resource':
+ ui.debug(b'read config from: resource:%s.%s\n' % (f[0], f[1]))
+ elif t == b'items':
+ # Don't print anything for 'items'.
+ pass
+ else:
+ raise error.ProgrammingError(b'unknown rctype: %s' % t)