# HG changeset patch # User Yuya Nishihara # Date 1519220867 -32400 # Node ID 199443c55463e8ab9425e70c783cae49c62232ce # Parent 07e207e88b42b4b3559e6105e0aed9ce0e12b2f4 showconfig: allow multiple section.name selectors (issue5797) This seems useful and we can disambiguate the output format solely by the type of the command arguments. diff -r 07e207e88b42 -r 199443c55463 mercurial/commands.py --- a/mercurial/commands.py Wed Feb 21 23:02:39 2018 +0900 +++ b/mercurial/commands.py Wed Feb 21 22:47:47 2018 +0900 @@ -1632,7 +1632,7 @@ of that config item. With multiple arguments, print names and values of all config - items with matching section names. + items with matching section names or section.names. With --edit, start an editor on the user-level config file. With --global, edit the system-wide config file. With --local, edit the @@ -1698,8 +1698,7 @@ if values: selsections = [v for v in values if '.' not in v] selentries = [v for v in values if '.' in v] - if len(selentries) > 1 or selentries and selsections: - raise error.Abort(_('only one config item permitted')) + uniquesel = (len(selentries) == 1 and not selsections) selsections = set(selsections) selentries = set(selentries) @@ -1711,23 +1710,16 @@ source = source or 'none' value = value.replace('\n', '\\n') entryname = section + '.' + name - if values: - if section in selsections: - fm.startitem() - fm.condwrite(ui.debugflag, 'source', '%s: ', source) - fm.write('name value', '%s=%s\n', entryname, value) - matched = True - elif entryname in selentries: - fm.startitem() - fm.condwrite(ui.debugflag, 'source', '%s: ', source) - fm.write('value', '%s\n', value) - fm.data(name=entryname) - matched = True + if values and not (section in selsections or entryname in selentries): + continue + fm.startitem() + fm.condwrite(ui.debugflag, 'source', '%s: ', source) + if uniquesel: + fm.data(name=entryname) + fm.write('value', '%s\n', value) else: - fm.startitem() - fm.condwrite(ui.debugflag, 'source', '%s: ', source) fm.write('name value', '%s=%s\n', entryname, value) - matched = True + matched = True fm.end() if matched: return 0 diff -r 07e207e88b42 -r 199443c55463 tests/test-hgrc.t --- a/tests/test-hgrc.t Wed Feb 21 23:02:39 2018 +0900 +++ b/tests/test-hgrc.t Wed Feb 21 22:47:47 2018 +0900 @@ -129,14 +129,13 @@ $ hg showconfig alias alias alias.log=log -g $ hg showconfig alias.log alias.log - abort: only one config item permitted - [255] + alias.log=log -g $ hg showconfig alias defaults.identify - abort: only one config item permitted - [255] + alias.log=log -g + defaults.identify=-n $ hg showconfig alias.log defaults.identify - abort: only one config item permitted - [255] + alias.log=log -g + defaults.identify=-n HGPLAIN