# HG changeset patch # User Yuya Nishihara # Date 1572147412 -32400 # Node ID a71578ec6257a5ca2d95624d2eee538dd716d09c # Parent 242ad45b60b3ad3f9824b5c8d3c649c239792ffe config: add support for defaultvalue of list of printable elements diff -r 242ad45b60b3 -r a71578ec6257 mercurial/commands.py --- a/mercurial/commands.py Sun Oct 27 12:30:59 2019 +0900 +++ b/mercurial/commands.py Sun Oct 27 12:36:52 2019 +0900 @@ -2269,6 +2269,10 @@ fm.write(b'name value', b'%s=%s\n', entryname, value) if formatter.isprintable(defaultvalue): fm.data(defaultvalue=defaultvalue) + elif isinstance(defaultvalue, list) and all( + formatter.isprintable(e) for e in defaultvalue + ): + fm.data(defaultvalue=fm.formatlist(defaultvalue, name=b'value')) # TODO: no idea how to process unsupported defaultvalue types matched = True fm.end() diff -r 242ad45b60b3 -r a71578ec6257 tests/test-config.t --- a/tests/test-config.t Sun Oct 27 12:30:59 2019 +0900 +++ b/tests/test-config.t Sun Oct 27 12:36:52 2019 +0900 @@ -186,6 +186,7 @@ $ hg config --config commands.show.aliasprefix= commands -Tjson [ { + "defaultvalue": [], "name": "commands.show.aliasprefix", "source": "--config", "value": "" @@ -193,7 +194,7 @@ ] $ hg config --config commands.show.aliasprefix= commands -T'json(defaultvalue)' [ - {"defaultvalue": ""} + {"defaultvalue": []} ] $ hg config --config commands.show.aliasprefix= commands -T'{defaultvalue}\n' @@ -203,6 +204,7 @@ $ hg config --config progress.format= progress -Tjson [ { + "defaultvalue": ["topic", "bar", "number", "estimate"], "name": "progress.format", "source": "--config", "value": "" @@ -210,10 +212,10 @@ ] $ hg config --config progress.format= progress -T'json(defaultvalue)' [ - {"defaultvalue": ""} + {"defaultvalue": ["topic", "bar", "number", "estimate"]} ] $ hg config --config progress.format= progress -T'{defaultvalue}\n' - + topic bar number estimate int