[Updated] D10356: config: add an experimental option to list all known config
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Thu Jun 17 13:31:27 UTC 2021
Closed by commit rHGb1b3127227be: config: add an experimental option to list all known config (authored by marmoute).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D10356?vs=28586&id=28587
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D10356/new/
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
@@ -408,6 +408,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, source, shared, non-shared, global, template
+ config: untrusted, exp-all-known, edit, local, source, 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
@@ -948,7 +948,48 @@
)
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_defined = next(defined, None)
+ current_known = next(known, 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
+ 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
@@ -2200,6 +2200,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')),
(b'', b'source', None, _(b'show source of configuration value')),
@@ -2336,8 +2351,10 @@
selentries = set(selentries)
matched = False
+ all_known = opts[b'exp_all_known']
show_source = ui.debugflag or opts.get(b'source')
- for section, name, value in ui.walkconfig(untrusted=untrusted):
+ 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, pulkit
Cc: mharbison72, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20210617/ee03cfd0/attachment-0001.html>
More information about the Mercurial-patches
mailing list