Mercurial > hg
diff tests/test-config.t @ 43335:242ad45b60b3 stable
config: fix -Tjson to not crash due to unsupported defaultvalue types
Maybe it isn't great to ignore unsupported types at all, but otherwise
"hg config -Tjson" would crash.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 27 Oct 2019 12:30:59 +0900 |
parents | 60789444acd6 |
children | a71578ec6257 |
line wrap: on
line diff
--- a/tests/test-config.t Sun Oct 27 18:12:24 2019 +0100 +++ b/tests/test-config.t Sun Oct 27 12:30:59 2019 +0900 @@ -87,6 +87,170 @@ } ] +Test config default of various types: + + {"defaultvalue": ""} for -T'json(defaultvalue)' looks weird, but that's + how the templater works. Unknown keywords are evaluated to "". + + dynamicdefault + + $ hg config --config alias.foo= alias -Tjson + [ + { + "name": "alias.foo", + "source": "--config", + "value": "" + } + ] + $ hg config --config alias.foo= alias -T'json(defaultvalue)' + [ + {"defaultvalue": ""} + ] + $ hg config --config alias.foo= alias -T'{defaultvalue}\n' + + + null + + $ hg config --config auth.cookiefile= auth -Tjson + [ + { + "defaultvalue": null, + "name": "auth.cookiefile", + "source": "--config", + "value": "" + } + ] + $ hg config --config auth.cookiefile= auth -T'json(defaultvalue)' + [ + {"defaultvalue": ""} + ] + $ hg config --config auth.cookiefile= auth -T'{defaultvalue}\n' + + + false + + $ hg config --config commands.commit.post-status= commands -Tjson + [ + { + "defaultvalue": false, + "name": "commands.commit.post-status", + "source": "--config", + "value": "" + } + ] + $ hg config --config commands.commit.post-status= commands -T'json(defaultvalue)' + [ + {"defaultvalue": false} + ] + $ hg config --config commands.commit.post-status= commands -T'{defaultvalue}\n' + False + + true + + $ hg config --config format.dotencode= format -Tjson + [ + { + "defaultvalue": true, + "name": "format.dotencode", + "source": "--config", + "value": "" + } + ] + $ hg config --config format.dotencode= format -T'json(defaultvalue)' + [ + {"defaultvalue": true} + ] + $ hg config --config format.dotencode= format -T'{defaultvalue}\n' + True + + bytes + + $ hg config --config commands.resolve.mark-check= commands -Tjson + [ + { + "defaultvalue": "none", + "name": "commands.resolve.mark-check", + "source": "--config", + "value": "" + } + ] + $ hg config --config commands.resolve.mark-check= commands -T'json(defaultvalue)' + [ + {"defaultvalue": "none"} + ] + $ hg config --config commands.resolve.mark-check= commands -T'{defaultvalue}\n' + none + + empty list + + $ hg config --config commands.show.aliasprefix= commands -Tjson + [ + { + "name": "commands.show.aliasprefix", + "source": "--config", + "value": "" + } + ] + $ hg config --config commands.show.aliasprefix= commands -T'json(defaultvalue)' + [ + {"defaultvalue": ""} + ] + $ hg config --config commands.show.aliasprefix= commands -T'{defaultvalue}\n' + + + nonempty list + + $ hg config --config progress.format= progress -Tjson + [ + { + "name": "progress.format", + "source": "--config", + "value": "" + } + ] + $ hg config --config progress.format= progress -T'json(defaultvalue)' + [ + {"defaultvalue": ""} + ] + $ hg config --config progress.format= progress -T'{defaultvalue}\n' + + + int + + $ hg config --config profiling.freq= profiling -Tjson + [ + { + "defaultvalue": 1000, + "name": "profiling.freq", + "source": "--config", + "value": "" + } + ] + $ hg config --config profiling.freq= profiling -T'json(defaultvalue)' + [ + {"defaultvalue": 1000} + ] + $ hg config --config profiling.freq= profiling -T'{defaultvalue}\n' + 1000 + + float + + $ hg config --config profiling.showmax= profiling -Tjson + [ + { + "defaultvalue": 0.999, + "name": "profiling.showmax", + "source": "--config", + "value": "" + } + ] + $ hg config --config profiling.showmax= profiling -T'json(defaultvalue)' + [ + {"defaultvalue": 0.999} + ] + $ hg config --config profiling.showmax= profiling -T'{defaultvalue}\n' + 0.999 + Test empty config source: $ cat <<EOF > emptysource.py