[PATCH S] dispatch: make sure global options on the command line take precedence

Idan Kamara idankk86 at gmail.com
Sat Jul 30 13:04:22 CDT 2011


# HG changeset patch
# User Idan Kamara <idankk86 at gmail.com>
# Date 1312049054 -10800
# Node ID 89f83b10ece32d90d43aee034d8dc055d717dd96
# Parent  cc2c22511707b13d045f17bb34e865d2393c53cf
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.

diff -r cc2c22511707 -r 89f83b10ece3 mercurial/dispatch.py
--- a/mercurial/dispatch.py	Fri Jul 29 17:27:38 2011 -0500
+++ b/mercurial/dispatch.py	Sat Jul 30 21:04:14 2011 +0300
@@ -601,11 +601,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:
diff -r cc2c22511707 -r 89f83b10ece3 tests/test-hgrc.t
--- a/tests/test-hgrc.t	Fri Jul 29 17:27:38 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


More information about the Mercurial-devel mailing list