D6712: config: fix defaultvalue template keyword
navaneeth.suresh (Navaneeth Suresh)
phabricator at mercurial-scm.org
Sat Aug 3 06:52:35 UTC 2019
navaneeth.suresh created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
This is a follow-up patch to 51a2e3102db2 <https://phab.mercurial-scm.org/rHG51a2e3102db2c24fffe6ee5594cca9189b6b0e4b>. This does three things.
- Shows a warning on `configitems.dynamicdefault`.
- Removes `pycompat.bytestr` to preserve `None`.
- Moves `pycompat.bytestr` out of the if loop.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D6712
AFFECTED FILES
mercurial/commands.py
mercurial/ui.py
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
@@ -57,11 +57,13 @@
$ hg showconfig Section -Tjson
[
{
+ "defaultvalue": null,
"name": "Section.KeY",
"source": "*.hgrc:*", (glob)
"value": "Case Sensitive"
},
{
+ "defaultvalue": null,
"name": "Section.key",
"source": "*.hgrc:*", (glob)
"value": "lower case"
@@ -70,15 +72,15 @@
$ hg showconfig Section.KeY -Tjson
[
{
- "defaultvalue": "None",
+ "defaultvalue": null,
"name": "Section.KeY",
"source": "*.hgrc:*", (glob)
"value": "Case Sensitive"
}
]
$ hg showconfig -Tjson | tail -7
- },
{
+ "defaultvalue": null,
"name": "*", (glob)
"source": "*", (glob)
"value": "*" (glob)
@@ -103,7 +105,7 @@
$ hg config empty.source -Tjson
[
{
- "defaultvalue": "None",
+ "defaultvalue": null,
"name": "empty.source",
"source": "",
"value": "value"
@@ -170,15 +172,19 @@
config affected by environment variables
$ EDITOR=e1 VISUAL=e2 hg config --debug | grep 'ui\.editor'
+ config item requires an explicit default value: 'ui.editor'
$VISUAL: ui.editor=e2
$ VISUAL=e2 hg config --debug --config ui.editor=e3 | grep 'ui\.editor'
+ config item requires an explicit default value: 'ui.editor'
--config: ui.editor=e3
$ PAGER=p1 hg config --debug | grep 'pager\.pager'
+ config item requires an explicit default value: 'pager.pager'
$PAGER: pager.pager=p1
$ PAGER=p1 hg config --debug --config pager.pager=p2 | grep 'pager\.pager'
+ config item requires an explicit default value: 'pager.pager'
--config: pager.pager=p2
verify that aliases are evaluated as well
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -792,7 +792,10 @@
itemdefault = item.default()
else:
itemdefault = item.default
- return itemdefault
+ if item.default is configitems.dynamicdefault:
+ self.warn(_("config item requires an explicit default value: "
+ "'%s.%s'\n" % (section, name)))
+ return itemdefault
def hasconfig(self, section, name, untrusted=False):
return self._data(untrusted).hasitem(section, name)
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1872,7 +1872,7 @@
for section, name, value in ui.walkconfig(untrusted=untrusted):
source = ui.configsource(section, name, untrusted)
value = pycompat.bytestr(value)
- defaultvalue = pycompat.bytestr(ui.configdefault(section, name))
+ defaultvalue = ui.configdefault(section, name)
if fm.isplain():
source = source or 'none'
value = value.replace('\n', '\\n')
@@ -1881,8 +1881,8 @@
continue
fm.startitem()
fm.condwrite(ui.debugflag, 'source', '%s: ', source)
+ fm.data(name=entryname, defaultvalue=defaultvalue)
if uniquesel:
- fm.data(name=entryname, defaultvalue=defaultvalue)
fm.write('value', '%s\n', value)
else:
fm.write('name value', '%s=%s\n', entryname, value)
To: navaneeth.suresh, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list