D6712: config: fix defaultvalue template keyword
navaneeth.suresh (Navaneeth Suresh)
phabricator at mercurial-scm.org
Tue Aug 6 17:04:55 UTC 2019
navaneeth.suresh updated this revision to Diff 16144.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D6712?vs=16118&id=16144
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D6712/new/
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
@@ -1876,7 +1876,7 @@
for section, name, value in walkconfig:
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')
@@ -1885,8 +1885,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