changeset 12697:14853ca7e11b

showconfig: don't accept multiple sections and one config item Showconfig now behaves as documented and only accepts one section.name argument or a number of section names.
author Brodie Rao <brodie@bitheap.org>
date Sat, 09 Oct 2010 16:55:33 -0500
parents ef969e58a394
children 7aef77e74cf3 0159a674a7bc
files mercurial/commands.py tests/test-hgrc.t
diffstat 2 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Sun Oct 10 17:35:28 2010 -0500
+++ b/mercurial/commands.py	Sat Oct 09 16:55:33 2010 -0500
@@ -1066,7 +1066,9 @@
         ui.debug(_('read config from: %s\n') % f)
     untrusted = bool(opts.get('untrusted'))
     if values:
-        if len([v for v in values if '.' in v]) > 1:
+        sections = [v for v in values if '.' not in v]
+        items = [v for v in values if '.' in v]
+        if len(items) > 1 or items and sections:
             raise util.Abort(_('only one config item permitted'))
     for section, name, value in ui.walkconfig(untrusted=untrusted):
         sectname = section + '.' + name
--- a/tests/test-hgrc.t	Sun Oct 10 17:35:28 2010 -0500
+++ b/tests/test-hgrc.t	Sat Oct 09 16:55:33 2010 -0500
@@ -75,6 +75,22 @@
   $ HGUSER=$olduser
   $ export HGUSER
 
+showconfig with multiple arguments
+
+  $ echo "[alias]" > $HGRCPATH
+  $ echo "log = log -g" >> $HGRCPATH
+  $ echo "[defaults]" >> $HGRCPATH
+  $ echo "identify = -n" >> $HGRCPATH
+  $ hg showconfig alias defaults
+  alias.log=log -g
+  defaults.identify=-n
+  $ hg showconfig alias defaults.identify
+  abort: only one config item permitted
+  [255]
+  $ hg showconfig alias.log defaults.identify
+  abort: only one config item permitted
+  [255]
+
 HGPLAIN
 
   $ cd ..