Patchwork [2,of,8,V2] color: add a 'ui.color' option to control color behavior

login
register
mail settings
Submitter Pierre-Yves David
Date Feb. 28, 2017, 10:54 a.m.
Message ID <8c0c36267c3db987aa9a.1488279266@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/18835/
State Accepted
Delegated to: Martin von Zweigbergk
Headers show

Comments

Pierre-Yves David - Feb. 28, 2017, 10:54 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1488048263 -3600
#      Sat Feb 25 19:44:23 2017 +0100
# Node ID 8c0c36267c3db987aa9a62df618380d087599ddb
# Parent  50ee9136a49a79ea381e3530eed8b114c76cdf7a
# EXP-Topic color
color: add a 'ui.color' option to control color behavior

This new option control whether or not color will be used. It mirror the behavior
of '--color'. I usually avoid adding new option to '[ui]' as the section is
already filled with many option. However, I feel like 'color' is central enough
to deserves a spot in this '[ui]' section.

For now the option is not documented so it is still marked as experimental. Once
it get documented and official, we should be able to deprecate the color
extensions.

There is more cleanup to do before that documentation is written, but we need
this option early to made them. Having that option will allow for more cleanup
of the initialisation process and proper separation between color
configuration.

Patch

diff --git a/hgext/color.py b/hgext/color.py
--- a/hgext/color.py
+++ b/hgext/color.py
@@ -187,10 +187,11 @@  testedwith = 'ships-with-hg-core'
 
 def extsetup(ui):
     # change default color config
+    color._enabledbydefault = True
     for idx, entry in enumerate(commands.globalopts):
         if entry[1] == 'color':
-            patch = ('auto', entry[3].replace(' (EXPERIMENTAL)', ''))
-            new = entry[:2] + patch + entry[4:]
+            patch = (entry[3].replace(' (EXPERIMENTAL)', ''),)
+            new = entry[:3] + patch + entry[4:]
             commands.globalopts[idx] = new
             break
 
diff --git a/mercurial/color.py b/mercurial/color.py
--- a/mercurial/color.py
+++ b/mercurial/color.py
@@ -43,6 +43,9 @@  except ImportError:
     curses = None
     _terminfo_params = {}
 
+# allow the extensions to change the default
+_enabledbydefault = False
+
 # start and stop parameters for effects
 _effects = {
     'none': 0,
@@ -167,25 +170,29 @@  def _terminfosetup(ui, mode):
               "ECMA-48 color\n"))
         _terminfo_params.clear()
 
-def setup(ui, coloropts):
+def setup(ui):
     """configure color on a ui
 
-    The 'coloropts' argument is the value of the '--color' command line
-    argument. That function both set the colormode for the ui object and read
+    That function both set the colormode for the ui object and read
     the configuration looking for custom colors and effect definitions."""
-    mode = _modesetup(ui, coloropts)
+    mode = _modesetup(ui)
     ui._colormode = mode
     if mode and mode != 'debug':
         configstyles(ui)
 
-def _modesetup(ui, coloropt):
+def _modesetup(ui):
     if ui.plain():
         return None
-    if coloropt == 'debug':
+    default = 'never'
+    if _enabledbydefault:
+        default = 'auto'
+    # experimental config: ui.color
+    config = ui.config('ui', 'color', default)
+    if config == 'debug':
         return 'debug'
 
-    auto = (coloropt == 'auto')
-    always = not auto and util.parsebool(coloropt)
+    auto = (config == 'auto')
+    always = not auto and util.parsebool(config)
     if not always and not auto:
         return None
 
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -77,7 +77,7 @@  globalopts = [
      _('do not prompt, automatically pick the first choice for all prompts')),
     ('q', 'quiet', None, _('suppress output')),
     ('v', 'verbose', None, _('enable additional output')),
-    ('', 'color', 'never',
+    ('', 'color', '',
      # i18n: 'always', 'auto', 'never', and 'debug' are keywords
      # and should not be translated
      _("when to colorize (boolean, always, auto, never, or debug)"
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -765,8 +765,11 @@  def _dispatch(req):
                 ui_.insecureconnections = True
 
         # setup color handling
+        coloropt = options['color']
         for ui_ in uis:
-            color.setup(ui_, options['color'])
+            if coloropt:
+                ui_.setconfig('ui', 'color', coloropt, '--color')
+            color.setup(ui_)
 
         if options['version']:
             return commands.version_(ui)
diff --git a/tests/test-diff-color.t b/tests/test-diff-color.t
--- a/tests/test-diff-color.t
+++ b/tests/test-diff-color.t
@@ -1,10 +1,10 @@ 
 Setup
 
   $ cat <<EOF >> $HGRCPATH
+  > [ui]
+  > color = always
   > [color]
   > mode = ansi
-  > [extensions]
-  > color =
   > EOF
   $ hg init repo
   $ cd repo
@@ -35,7 +35,7 @@  Setup
 
 default context
 
-  $ hg diff --nodates --color=always
+  $ hg diff --nodates
   \x1b[0;1mdiff -r cf9f4ba66af2 a\x1b[0m (esc)
   \x1b[0;31;1m--- a/a\x1b[0m (esc)
   \x1b[0;32;1m+++ b/a\x1b[0m (esc)
@@ -51,7 +51,7 @@  default context
 
 --unified=2
 
-  $ hg diff --nodates -U 2  --color=always
+  $ hg diff --nodates -U 2
   \x1b[0;1mdiff -r cf9f4ba66af2 a\x1b[0m (esc)
   \x1b[0;31;1m--- a/a\x1b[0m (esc)
   \x1b[0;32;1m+++ b/a\x1b[0m (esc)
@@ -65,10 +65,11 @@  default context
 
 diffstat
 
-  $ hg diff --stat --color=always
+  $ hg diff --stat
    a |  2 \x1b[0;32m+\x1b[0m\x1b[0;31m-\x1b[0m (esc)
    1 files changed, 1 insertions(+), 1 deletions(-)
   $ cat <<EOF >> $HGRCPATH
+  > [extensions]
   > record =
   > [ui]
   > interactive = true
@@ -81,7 +82,7 @@  diffstat
 record
 
   $ chmod +x a
-  $ hg record --color=always -m moda a <<EOF
+  $ hg record -m moda a <<EOF
   > y
   > y
   > EOF
@@ -111,7 +112,7 @@  record
 
 qrecord
 
-  $ hg qrecord --color=always -m moda patch <<EOF
+  $ hg qrecord -m moda patch <<EOF
   > y
   > y
   > EOF
@@ -151,7 +152,7 @@  issue3712: test colorization of subrepo 
   $ echo aa >> a
   $ echo bb >> sub/b
 
-  $ hg diff --color=always -S
+  $ hg diff -S
   \x1b[0;1mdiff --git a/a b/a\x1b[0m (esc)
   \x1b[0;31;1m--- a/a\x1b[0m (esc)
   \x1b[0;32;1m+++ b/a\x1b[0m (esc)
@@ -176,7 +177,7 @@  test tabs
   > mid	tab
   > 	all		tabs	
   > EOF
-  $ hg diff --nodates --color=always
+  $ hg diff --nodates
   \x1b[0;1mdiff --git a/a b/a\x1b[0m (esc)
   \x1b[0;31;1m--- a/a\x1b[0m (esc)
   \x1b[0;32;1m+++ b/a\x1b[0m (esc)
@@ -192,7 +193,7 @@  test tabs
   \x1b[0;32m+\x1b[0m	\x1b[0;32mall\x1b[0m		\x1b[0;32mtabs\x1b[0m\x1b[0;1;41m	\x1b[0m (esc)
   $ echo "[color]" >> $HGRCPATH
   $ echo "diff.tab = bold magenta" >> $HGRCPATH
-  $ hg diff --nodates --color=always
+  $ hg diff --nodates
   \x1b[0;1mdiff --git a/a b/a\x1b[0m (esc)
   \x1b[0;31;1m--- a/a\x1b[0m (esc)
   \x1b[0;32;1m+++ b/a\x1b[0m (esc)
diff --git a/tests/test-extension.t b/tests/test-extension.t
--- a/tests/test-extension.t
+++ b/tests/test-extension.t
@@ -533,7 +533,7 @@  hide outer repo
    -q --quiet             suppress output
    -v --verbose           enable additional output
       --color TYPE        when to colorize (boolean, always, auto, never, or
-                          debug) (EXPERIMENTAL) (default: never)
+                          debug) (EXPERIMENTAL)
       --config CONFIG [+] set/override config option (use 'section.name=value')
       --debug             enable debugging output
       --debugger          start debugger
@@ -572,7 +572,7 @@  hide outer repo
    -q --quiet             suppress output
    -v --verbose           enable additional output
       --color TYPE        when to colorize (boolean, always, auto, never, or
-                          debug) (EXPERIMENTAL) (default: never)
+                          debug) (EXPERIMENTAL)
       --config CONFIG [+] set/override config option (use 'section.name=value')
       --debug             enable debugging output
       --debugger          start debugger
@@ -854,7 +854,7 @@  extension help itself
    -q --quiet             suppress output
    -v --verbose           enable additional output
       --color TYPE        when to colorize (boolean, always, auto, never, or
-                          debug) (EXPERIMENTAL) (default: never)
+                          debug) (EXPERIMENTAL)
       --config CONFIG [+] set/override config option (use 'section.name=value')
       --debug             enable debugging output
       --debugger          start debugger
@@ -891,7 +891,7 @@  Make sure that single '-v' option shows 
    -q --quiet             suppress output
    -v --verbose           enable additional output
       --color TYPE        when to colorize (boolean, always, auto, never, or
-                          debug) (EXPERIMENTAL) (default: never)
+                          debug) (EXPERIMENTAL)
       --config CONFIG [+] set/override config option (use 'section.name=value')
       --debug             enable debugging output
       --debugger          start debugger
@@ -966,7 +966,7 @@  help options '-v' and '-v -e' should be 
    -q --quiet             suppress output
    -v --verbose           enable additional output
       --color TYPE        when to colorize (boolean, always, auto, never, or
-                          debug) (EXPERIMENTAL) (default: never)
+                          debug) (EXPERIMENTAL)
       --config CONFIG [+] set/override config option (use 'section.name=value')
       --debug             enable debugging output
       --debugger          start debugger
@@ -1002,7 +1002,7 @@  help options '-v' and '-v -e' should be 
    -q --quiet             suppress output
    -v --verbose           enable additional output
       --color TYPE        when to colorize (boolean, always, auto, never, or
-                          debug) (EXPERIMENTAL) (default: never)
+                          debug) (EXPERIMENTAL)
       --config CONFIG [+] set/override config option (use 'section.name=value')
       --debug             enable debugging output
       --debugger          start debugger
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -317,7 +317,7 @@  Test short command list with verbose opt
    -q --quiet             suppress output
    -v --verbose           enable additional output
       --color TYPE        when to colorize (boolean, always, auto, never, or
-                          debug) (EXPERIMENTAL) (default: never)
+                          debug) (EXPERIMENTAL)
       --config CONFIG [+] set/override config option (use 'section.name=value')
       --debug             enable debugging output
       --debugger          start debugger
@@ -417,7 +417,7 @@  Verbose help for add
    -q --quiet             suppress output
    -v --verbose           enable additional output
       --color TYPE        when to colorize (boolean, always, auto, never, or
-                          debug) (EXPERIMENTAL) (default: never)
+                          debug) (EXPERIMENTAL)
       --config CONFIG [+] set/override config option (use 'section.name=value')
       --debug             enable debugging output
       --debugger          start debugger
@@ -2521,7 +2521,7 @@  Dish up an empty repo; serve it cold.
   <td>enable additional output</td></tr>
   <tr><td></td>
   <td>--color TYPE</td>
-  <td>when to colorize (boolean, always, auto, never, or debug) (EXPERIMENTAL) (default: never)</td></tr>
+  <td>when to colorize (boolean, always, auto, never, or debug) (EXPERIMENTAL)</td></tr>
   <tr><td></td>
   <td>--config CONFIG [+]</td>
   <td>set/override config option (use 'section.name=value')</td></tr>
@@ -2722,7 +2722,7 @@  Dish up an empty repo; serve it cold.
   <td>enable additional output</td></tr>
   <tr><td></td>
   <td>--color TYPE</td>
-  <td>when to colorize (boolean, always, auto, never, or debug) (EXPERIMENTAL) (default: never)</td></tr>
+  <td>when to colorize (boolean, always, auto, never, or debug) (EXPERIMENTAL)</td></tr>
   <tr><td></td>
   <td>--config CONFIG [+]</td>
   <td>set/override config option (use 'section.name=value')</td></tr>
diff --git a/tests/test-status-color.t b/tests/test-status-color.t
--- a/tests/test-status-color.t
+++ b/tests/test-status-color.t
@@ -1,6 +1,6 @@ 
   $ cat <<EOF >> $HGRCPATH
-  > [extensions]
-  > color =
+  > [ui]
+  > color = always
   > [color]
   > mode = ansi
   > EOF
@@ -14,7 +14,7 @@  Terminfo codes compatibility fix
 
 hg status in repo root:
 
-  $ hg status --color=always
+  $ hg status
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4ma/1/in_a_1\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4ma/in_a\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4mb/1/in_b_1\x1b[0m (esc)
@@ -41,7 +41,7 @@  hg status with template
 
 hg status . in repo root:
 
-  $ hg status --color=always .
+  $ hg status .
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4ma/1/in_a_1\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4ma/in_a\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4mb/1/in_b_1\x1b[0m (esc)
@@ -49,17 +49,17 @@  hg status . in repo root:
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4mb/in_b\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4min_root\x1b[0m (esc)
 
-  $ hg status --color=always --cwd a
+  $ hg status --cwd a
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4ma/1/in_a_1\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4ma/in_a\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4mb/1/in_b_1\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4mb/2/in_b_2\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4mb/in_b\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4min_root\x1b[0m (esc)
-  $ hg status --color=always --cwd a .
+  $ hg status --cwd a .
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4m1/in_a_1\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4min_a\x1b[0m (esc)
-  $ hg status --color=always --cwd a ..
+  $ hg status --cwd a ..
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4m1/in_a_1\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4min_a\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4m../b/1/in_b_1\x1b[0m (esc)
@@ -67,18 +67,18 @@  hg status . in repo root:
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4m../b/in_b\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4m../in_root\x1b[0m (esc)
 
-  $ hg status --color=always --cwd b
+  $ hg status --cwd b
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4ma/1/in_a_1\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4ma/in_a\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4mb/1/in_b_1\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4mb/2/in_b_2\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4mb/in_b\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4min_root\x1b[0m (esc)
-  $ hg status --color=always --cwd b .
+  $ hg status --cwd b .
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4m1/in_b_1\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4m2/in_b_2\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4min_b\x1b[0m (esc)
-  $ hg status --color=always --cwd b ..
+  $ hg status --cwd b ..
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4m../a/1/in_a_1\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4m../a/in_a\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4m1/in_b_1\x1b[0m (esc)
@@ -86,43 +86,43 @@  hg status . in repo root:
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4min_b\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4m../in_root\x1b[0m (esc)
 
-  $ hg status --color=always --cwd a/1
+  $ hg status --cwd a/1
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4ma/1/in_a_1\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4ma/in_a\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4mb/1/in_b_1\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4mb/2/in_b_2\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4mb/in_b\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4min_root\x1b[0m (esc)
-  $ hg status --color=always --cwd a/1 .
+  $ hg status --cwd a/1 .
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4min_a_1\x1b[0m (esc)
-  $ hg status --color=always --cwd a/1 ..
+  $ hg status --cwd a/1 ..
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4min_a_1\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4m../in_a\x1b[0m (esc)
 
-  $ hg status --color=always --cwd b/1
+  $ hg status --cwd b/1
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4ma/1/in_a_1\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4ma/in_a\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4mb/1/in_b_1\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4mb/2/in_b_2\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4mb/in_b\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4min_root\x1b[0m (esc)
-  $ hg status --color=always --cwd b/1 .
+  $ hg status --cwd b/1 .
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4min_b_1\x1b[0m (esc)
-  $ hg status --color=always --cwd b/1 ..
+  $ hg status --cwd b/1 ..
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4min_b_1\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4m../2/in_b_2\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4m../in_b\x1b[0m (esc)
 
-  $ hg status --color=always --cwd b/2
+  $ hg status --cwd b/2
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4ma/1/in_a_1\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4ma/in_a\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4mb/1/in_b_1\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4mb/2/in_b_2\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4mb/in_b\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4min_root\x1b[0m (esc)
-  $ hg status --color=always --cwd b/2 .
+  $ hg status --cwd b/2 .
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4min_b_2\x1b[0m (esc)
-  $ hg status --color=always --cwd b/2 ..
+  $ hg status --cwd b/2 ..
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4m../1/in_b_1\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4min_b_2\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4m../in_b\x1b[0m (esc)
@@ -137,7 +137,7 @@  Make sure --color=never works
   ? in_root
 
 Make sure ui.formatted=False works
-  $ hg status --config ui.formatted=False
+  $ hg status --color=auto --config ui.formatted=False
   ? a/1/in_a_1
   ? a/in_a
   ? b/1/in_b_1
@@ -179,7 +179,7 @@  templates should be.
 
 hg status:
 
-  $ hg status --color=always
+  $ hg status
   \x1b[0;32;1mA \x1b[0m\x1b[0;32;1madded\x1b[0m (esc)
   \x1b[0;31;1mR \x1b[0m\x1b[0;31;1mremoved\x1b[0m (esc)
   \x1b[0;36;1;4m! \x1b[0m\x1b[0;36;1;4mdeleted\x1b[0m (esc)
@@ -187,7 +187,7 @@  hg status:
 
 hg status modified added removed deleted unknown never-existed ignored:
 
-  $ hg status --color=always modified added removed deleted unknown never-existed ignored
+  $ hg status modified added removed deleted unknown never-existed ignored
   never-existed: * (glob)
   \x1b[0;32;1mA \x1b[0m\x1b[0;32;1madded\x1b[0m (esc)
   \x1b[0;31;1mR \x1b[0m\x1b[0;31;1mremoved\x1b[0m (esc)
@@ -198,7 +198,7 @@  hg status modified added removed deleted
 
 hg status -C:
 
-  $ hg status --color=always -C
+  $ hg status -C
   \x1b[0;32;1mA \x1b[0m\x1b[0;32;1madded\x1b[0m (esc)
   \x1b[0;32;1mA \x1b[0m\x1b[0;32;1mcopied\x1b[0m (esc)
   \x1b[0;0m  modified\x1b[0m (esc)
@@ -208,7 +208,7 @@  hg status -C:
 
 hg status -A:
 
-  $ hg status --color=always -A
+  $ hg status -A
   \x1b[0;32;1mA \x1b[0m\x1b[0;32;1madded\x1b[0m (esc)
   \x1b[0;32;1mA \x1b[0m\x1b[0;32;1mcopied\x1b[0m (esc)
   \x1b[0;0m  modified\x1b[0m (esc)
@@ -226,7 +226,7 @@  hg status -A (with terminfo color):
 
   $ mkdir "$TESTTMP/terminfo"
   $ TERMINFO="$TESTTMP/terminfo" tic "$TESTDIR/hgterm.ti"
-  $ TERM=hgterm TERMINFO="$TESTTMP/terminfo" hg status --config color.mode=terminfo --color=always -A
+  $ TERM=hgterm TERMINFO="$TESTTMP/terminfo" hg status --config color.mode=terminfo -A
   \x1b[30m\x1b[32m\x1b[1mA \x1b[30m\x1b[30m\x1b[32m\x1b[1madded\x1b[30m (esc)
   \x1b[30m\x1b[32m\x1b[1mA \x1b[30m\x1b[30m\x1b[32m\x1b[1mcopied\x1b[30m (esc)
   \x1b[30m\x1b[30m  modified\x1b[30m (esc)
@@ -245,7 +245,7 @@  The user can define effects with raw ter
   > # We can override what's in the terminfo database, too
   > terminfo.bold = \E[2m
   > EOF
-  $ TERM=hgterm TERMINFO="$TESTTMP/terminfo" hg status --config color.mode=terminfo --config color.status.clean=dim --color=always -A
+  $ TERM=hgterm TERMINFO="$TESTTMP/terminfo" hg status --config color.mode=terminfo --config color.status.clean=dim -A
   \x1b[30m\x1b[32m\x1b[2mA \x1b[30m\x1b[30m\x1b[32m\x1b[2madded\x1b[30m (esc)
   \x1b[30m\x1b[32m\x1b[2mA \x1b[30m\x1b[30m\x1b[32m\x1b[2mcopied\x1b[30m (esc)
   \x1b[30m\x1b[30m  modified\x1b[30m (esc)
@@ -265,11 +265,11 @@  The user can define effects with raw ter
 
 hg status ignoreddir/file:
 
-  $ hg status --color=always ignoreddir/file
+  $ hg status ignoreddir/file
 
 hg status -i ignoreddir/file:
 
-  $ hg status --color=always -i ignoreddir/file
+  $ hg status -i ignoreddir/file
   \x1b[0;30;1mI \x1b[0m\x1b[0;30;1mignoreddir/file\x1b[0m (esc)
   $ cd ..
 
@@ -293,7 +293,7 @@  check 'status -q' and some combinations
 
 test unknown color
 
-  $ hg --config color.status.modified=periwinkle status --color=always
+  $ hg --config color.status.modified=periwinkle status
   ignoring unknown color/effect 'periwinkle' (configured in color.status.modified)
   ignoring unknown color/effect 'periwinkle' (configured in color.status.modified)
   M modified
@@ -308,8 +308,8 @@  Check if result is the same or different
 If result is not as expected, raise error
 
   $ assert() {
-  >     hg status --color=always $1 > ../a
-  >     hg status --color=always $2 > ../b
+  >     hg status $1 > ../a
+  >     hg status $2 > ../b
   >     if diff ../a ../b > /dev/null; then
   >         out=0
   >     else
@@ -368,7 +368,7 @@  test 'resolve -l'
 
 hg resolve with one unresolved, one resolved:
 
-  $ hg resolve --color=always -l
+  $ hg resolve -l
   \x1b[0;31;1mU \x1b[0m\x1b[0;31;1ma\x1b[0m (esc)
   \x1b[0;32;1mR \x1b[0m\x1b[0;32;1mb\x1b[0m (esc)