D10356: config: add an experimental option to list all known config
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Fri Apr 9 18:07:36 UTC 2021
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
That option is not ready for prime-time, hence the `exp-` prefix. However, this
is a good base to start going toward completion. This is also quite useful for
developer on its own for now.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D10356
AFFECTED FILES
mercurial/commands.py
mercurial/ui.py
tests/test-completion.t
tests/test-config.t
CHANGE DETAILS
diff --git a/tests/test-config.t b/tests/test-config.t
--- a/tests/test-config.t
+++ b/tests/test-config.t
@@ -403,6 +403,32 @@
$ HGRCPATH=configs hg config section.key
99
+Listing all config options
+==========================
+
+The feature is experimental and behavior may varies. This test exists to make sure the code is run. We grep it to avoid too much variability in its current experimental state.
+
+ $ hg config --exp-all-known | grep commit
+ commands.commit.interactive.git=False
+ commands.commit.interactive.ignoreblanklines=False
+ commands.commit.interactive.ignorews=False
+ commands.commit.interactive.ignorewsamount=False
+ commands.commit.interactive.ignorewseol=False
+ commands.commit.interactive.nobinary=False
+ commands.commit.interactive.nodates=False
+ commands.commit.interactive.noprefix=False
+ commands.commit.interactive.showfunc=False
+ commands.commit.interactive.unified=None
+ commands.commit.interactive.word-diff=False
+ commands.commit.post-status=False
+ convert.git.committeractions=[*'messagedifferent'] (glob)
+ convert.svn.dangerous-set-commit-dates=False
+ experimental.copytrace.sourcecommitlimit=100
+ phases.new-commit=draft
+ ui.allowemptycommit=False
+ ui.commitsubrepos=False
+
+
Configuration priority
======================
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -262,7 +262,7 @@
cat: output, rev, decode, include, exclude, template
clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, remotecmd, insecure
commit: addremove, close-branch, amend, secret, edit, force-close-branch, interactive, include, exclude, message, logfile, date, user, subrepos
- config: untrusted, edit, local, shared, non-shared, global, template
+ config: untrusted, exp-all-known, edit, local, shared, non-shared, global, template
continue: dry-run
copy: forget, after, at-rev, force, include, exclude, dry-run
debugancestor:
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -942,7 +942,49 @@
)
return items
- def walkconfig(self, untrusted=False):
+ def walkconfig(self, untrusted=False, all_known=False):
+ defined = self._walk_config(untrusted)
+ if not all_known:
+ for d in defined:
+ yield d
+ return
+ known = self._walk_known()
+ current_defined = next(defined, None)
+ current_known = next(known, None)
+ while current_defined is not None or current_known is not None:
+ if current_defined is None:
+ yield current_known
+ current_known = next(known, None)
+ elif current_known is None:
+ yield current_defined
+ current_defined = next(defined, None)
+ elif current_known[0:2] == current_defined[0:2]:
+ yield current_defined
+ current_known = next(known, None)
+ current_defined = next(defined, None)
+ elif current_known[0:2] < current_defined[0:2]:
+ yield current_known
+ current_known = next(known, None)
+ else:
+ yield current_defined
+ current_defined = next(defined, None)
+
+ def _walk_known(self):
+ for section, items in sorted(self._knownconfig.items()):
+ for k, i in sorted(items.items()):
+ # We don't have a way to display generic well, so skip them
+ if i.generic:
+ continue
+ # We don't have a way to display generic well, so skip them
+ if callable(i.default):
+ default = i.default()
+ elif i.default is configitems.dynamicdefault:
+ default = b'<DYNAMIC>'
+ else:
+ default = i.default
+ yield section, i.name, default
+
+ def _walk_config(self, untrusted):
cfg = self._data(untrusted)
for section in cfg.sections():
for name, value in self.configitems(section, untrusted):
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2178,6 +2178,21 @@
b'config|showconfig|debugconfig',
[
(b'u', b'untrusted', None, _(b'show untrusted configuration options')),
+ # This is experimental because we need
+ # * reasonable behavior around aliases,
+ # * decide if we display [debug] [experimental] and [devel] section par
+ # default
+ # * some way to display "generic" config entry (the one matching
+ # regexp,
+ # * proper display of the different value type
+ # * a better way to handle <DYNAMIC> values (and variable types),
+ # * maybe some type information ?
+ (
+ b'',
+ b'exp-all-known',
+ None,
+ _(b'show all known config option (EXPERIMENTAL)'),
+ ),
(b'e', b'edit', None, _(b'edit user config')),
(b'l', b'local', None, _(b'edit repository config')),
(
@@ -2313,7 +2328,9 @@
selentries = set(selentries)
matched = False
- for section, name, value in ui.walkconfig(untrusted=untrusted):
+ all_known = opts[b'exp_all_known']
+ entries = ui.walkconfig(untrusted=untrusted, all_known=all_known)
+ for section, name, value in entries:
source = ui.configsource(section, name, untrusted)
value = pycompat.bytestr(value)
defaultvalue = ui.configdefault(section, name)
To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list