dispatch: make sure global options on the command line take precedence stable
authorIdan Kamara <idankk86@gmail.com>
Sat, 30 Jul 2011 21:04:14 +0300
branchstable
changeset 14992 188936b334b1
parent 14991 4f39610996fa
child 14993 e5b2ee5157ae
dispatch: make sure global options on the command line take precedence So if a user has verbose=True somewhere in his .hgrc files, giving -q on the command line will override that. This basically reverts 1b8c70c9f47c.
mercurial/dispatch.py
tests/test-hgrc.t
--- a/mercurial/dispatch.py	Wed Jul 27 18:35:35 2011 -0500
+++ b/mercurial/dispatch.py	Sat Jul 30 21:04:14 2011 +0300
@@ -608,11 +608,15 @@
         for cfg in cfgs:
             req.repo.ui.setconfig(*cfg)
 
-    for opt in ('verbose', 'debug', 'quiet', 'traceback'):
-        val = bool(options[opt])
-        if val:
+    if options['verbose'] or options['debug'] or options['quiet']:
+        for opt in ('verbose', 'debug', 'quiet'):
+            val = str(bool(options[opt]))
             for ui_ in uis:
-                ui_.setconfig('ui', opt, str(val))
+                ui_.setconfig('ui', opt, val)
+
+    if options['traceback']:
+        for ui_ in uis:
+            ui_.setconfig('ui', 'traceback', 'on')
 
     if options['noninteractive']:
         for ui_ in uis:
--- a/tests/test-hgrc.t	Wed Jul 27 18:35:35 2011 -0500
+++ b/tests/test-hgrc.t	Sat Jul 30 21:04:14 2011 +0300
@@ -54,12 +54,20 @@
   warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   $ unset FAKEPATH
 
-make sure unspecified global ui options don't override old values
+make sure global options given on the cmdline take precedence
 
   $ hg showconfig --config ui.verbose=True --quiet
-  ui.verbose=True
+  ui.verbose=False
+  ui.debug=False
   ui.quiet=True
 
+  $ touch foobar/untracked
+  $ cat >> foobar/.hg/hgrc <<EOF
+  > [ui]
+  > verbose=True
+  > EOF
+  $ hg -R foobar st -q
+
 username expansion
 
   $ olduser=$HGUSER
@@ -140,7 +148,9 @@
   $ hg showconfig --config ui.traceback=True --debug
   read config from: $TESTTMP/hgrc
   none: ui.traceback=True
+  none: ui.verbose=False
   none: ui.debug=True
+  none: ui.quiet=False
 
 plain mode with exceptions
 
@@ -156,18 +166,24 @@
   read config from: $TESTTMP/hgrc
   $TESTTMP/hgrc:15: extensions.plain=./plain.py
   none: ui.traceback=True
+  none: ui.verbose=False
   none: ui.debug=True
+  none: ui.quiet=False
   $ unset HGPLAIN
   $ hg showconfig --config ui.traceback=True --debug
   plain: True
   read config from: $TESTTMP/hgrc
   $TESTTMP/hgrc:15: extensions.plain=./plain.py
   none: ui.traceback=True
+  none: ui.verbose=False
   none: ui.debug=True
+  none: ui.quiet=False
   $ HGPLAINEXCEPT=i18n; export HGPLAINEXCEPT
   $ hg showconfig --config ui.traceback=True --debug
   plain: True
   read config from: $TESTTMP/hgrc
   $TESTTMP/hgrc:15: extensions.plain=./plain.py
   none: ui.traceback=True
+  none: ui.verbose=False
   none: ui.debug=True
+  none: ui.quiet=False