[PATCH] dispatch: make sure unspecified global ui options don't override old values

Idan Kamara idankk86 at gmail.com
Fri Jun 24 04:25:13 CDT 2011


# HG changeset patch
# User Idan Kamara <idankk86 at gmail.com>
# Date 1308906974 -10800
# Branch stable
# Node ID 6fe55159c4326e0cc8d180125a575023127f1c46
# Parent  9e43cfc53832c186a8ac0fc03b3b0360cf07eb68
dispatch: make sure unspecified global ui options don't override old values

diff -r 9e43cfc53832 -r 6fe55159c432 mercurial/dispatch.py
--- a/mercurial/dispatch.py	Fri Jun 24 11:12:19 2011 +0300
+++ b/mercurial/dispatch.py	Fri Jun 24 12:16:14 2011 +0300
@@ -594,14 +594,12 @@
                 (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3]))
         atexit.register(print_time)
 
-    if options['verbose'] or options['debug'] or options['quiet']:
-        for ui_ in (ui, lui):
-            ui_.setconfig('ui', 'verbose', str(bool(options['verbose'])))
-            ui_.setconfig('ui', 'debug', str(bool(options['debug'])))
-            ui_.setconfig('ui', 'quiet', str(bool(options['quiet'])))
-    if options['traceback']:
-        for ui_ in (ui, lui):
-            ui_.setconfig('ui', 'traceback', 'on')
+    for opt in ('verbose', 'debug', 'quiet', 'traceback'):
+        val = bool(options[opt])
+        if val:
+            for ui_ in (ui, lui):
+                ui_.setconfig('ui', opt, str(val))
+
     if options['noninteractive']:
         for ui_ in (ui, lui):
             ui_.setconfig('ui', 'interactive', 'off')
diff -r 9e43cfc53832 -r 6fe55159c432 tests/test-hgrc.t
--- a/tests/test-hgrc.t	Fri Jun 24 11:12:19 2011 +0300
+++ b/tests/test-hgrc.t	Fri Jun 24 12:16:14 2011 +0300
@@ -54,6 +54,12 @@
   warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   $ unset FAKEPATH
 
+make sure unspecified global ui options don't override old values
+
+  $ hg showconfig --config ui.verbose=True --quiet
+  ui.verbose=True
+  ui.quiet=True
+
 username expansion
 
   $ olduser=$HGUSER
@@ -134,9 +140,7 @@
   $ 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
 
@@ -152,24 +156,18 @@
   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