Patchwork [5,of,7] color: add the definition of '--color' in core

login
register
mail settings
Submitter Pierre-Yves David
Date Feb. 25, 2017, 1:11 p.m.
Message ID <25fd71d9347a8c82adf2.1488028297@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/18782/
State Accepted
Headers show

Comments

Pierre-Yves David - Feb. 25, 2017, 1:11 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1487696961 -3600
#      Tue Feb 21 18:09:21 2017 +0100
# Node ID 25fd71d9347a8c82adf2a991dab0b48ff35282f6
# Parent  1b39bb158cdb97965da0b614b7c8bcd6a8b58887
# EXP-Topic color
color: add the definition of '--color' in core

If we want to be able to move the initialisation in core, we need core to be
aware of that '--color' flag at all time. So we now have the definition in core. That flag
is currently unprocessed without the extensions (will be fixed soon). In
addition the default value for this flag in core is 'never'. Enabling the
extensions change that default value to 'auto'.
Yuya Nishihara - Feb. 27, 2017, 2:41 p.m.
On Sat, 25 Feb 2017 14:11:37 +0100, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
> # Date 1487696961 -3600
> #      Tue Feb 21 18:09:21 2017 +0100
> # Node ID 25fd71d9347a8c82adf2a991dab0b48ff35282f6
> # Parent  1b39bb158cdb97965da0b614b7c8bcd6a8b58887
> # EXP-Topic color
> color: add the definition of '--color' in core

> diff -r 1b39bb158cdb -r 25fd71d9347a hgext/color.py
> --- a/hgext/color.py	Tue Feb 21 17:51:43 2017 +0100
> +++ b/hgext/color.py	Tue Feb 21 18:09:21 2017 +0100
> @@ -198,12 +198,13 @@ def uisetup(ui):
>      extensions.wrapfunction(dispatch, '_runcommand', colorcmd)
>  
>  def extsetup(ui):
> -    commands.globalopts.append(
> -        ('', 'color', 'auto',
> -         # i18n: 'always', 'auto', 'never', and 'debug' are keywords
> -         # and should not be translated
> -         _("when to colorize (boolean, always, auto, never, or debug)"),
> -         _('TYPE')))
> +    # change default color config
> +    for idx, entry in enumerate(commands.globalopts):
> +        if entry[1] == 'color':
> +            patch = ('auto', entry[3].replace(' (EXPERIMENTAL', ''))
                                                    ^^^^^^^^^^^^

Missed ')', fixed.

This won't work if the message is translated, but I expect the color extension
will be deprecated soon and the problem will go away.

Patch

diff -r 1b39bb158cdb -r 25fd71d9347a hgext/color.py
--- a/hgext/color.py	Tue Feb 21 17:51:43 2017 +0100
+++ b/hgext/color.py	Tue Feb 21 18:09:21 2017 +0100
@@ -198,12 +198,13 @@  def uisetup(ui):
     extensions.wrapfunction(dispatch, '_runcommand', colorcmd)
 
 def extsetup(ui):
-    commands.globalopts.append(
-        ('', 'color', 'auto',
-         # i18n: 'always', 'auto', 'never', and 'debug' are keywords
-         # and should not be translated
-         _("when to colorize (boolean, always, auto, never, or debug)"),
-         _('TYPE')))
+    # change default color config
+    for idx, entry in enumerate(commands.globalopts):
+        if entry[1] == 'color':
+            patch = ('auto', entry[3].replace(' (EXPERIMENTAL', ''))
+            new = entry[:2] + patch + entry[4:]
+            commands.globalopts[idx] = new
+            break
 
 @command('debugcolor',
         [('', 'style', None, _('show all configured styles'))],
diff -r 1b39bb158cdb -r 25fd71d9347a mercurial/commands.py
--- a/mercurial/commands.py	Tue Feb 21 17:51:43 2017 +0100
+++ b/mercurial/commands.py	Tue Feb 21 18:09:21 2017 +0100
@@ -77,6 +77,12 @@  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',
+     # i18n: 'always', 'auto', 'never', and 'debug' are keywords
+     # and should not be translated
+     _("when to colorize (boolean, always, auto, never, or debug)"
+       " (EXPERIMENTAL)"),
+     _('TYPE')),
     ('', 'config', [],
      _('set/override config option (use \'section.name=value\')'),
      _('CONFIG')),
diff -r 1b39bb158cdb -r 25fd71d9347a tests/test-completion.t
--- a/tests/test-completion.t	Tue Feb 21 17:51:43 2017 +0100
+++ b/tests/test-completion.t	Tue Feb 21 18:09:21 2017 +0100
@@ -129,6 +129,7 @@  Show the alias of a debug command if the
 
 Show the global options
   $ hg debugcomplete --options | sort
+  --color
   --config
   --cwd
   --debug
@@ -158,6 +159,7 @@  Show the options for the "serve" command
   --address
   --certificate
   --cmdserver
+  --color
   --config
   --cwd
   --daemon
diff -r 1b39bb158cdb -r 25fd71d9347a tests/test-extension.t
--- a/tests/test-extension.t	Tue Feb 21 17:51:43 2017 +0100
+++ b/tests/test-extension.t	Tue Feb 21 18:09:21 2017 +0100
@@ -532,6 +532,8 @@  hide outer repo
                           all prompts
    -q --quiet             suppress output
    -v --verbose           enable additional output
+      --color TYPE        when to colorize (boolean, always, auto, never, or
+                          debug) (EXPERIMENTAL) (default: never)
       --config CONFIG [+] set/override config option (use 'section.name=value')
       --debug             enable debugging output
       --debugger          start debugger
@@ -569,6 +571,8 @@  hide outer repo
                           all prompts
    -q --quiet             suppress output
    -v --verbose           enable additional output
+      --color TYPE        when to colorize (boolean, always, auto, never, or
+                          debug) (EXPERIMENTAL) (default: never)
       --config CONFIG [+] set/override config option (use 'section.name=value')
       --debug             enable debugging output
       --debugger          start debugger
@@ -849,6 +853,8 @@  extension help itself
                           all prompts
    -q --quiet             suppress output
    -v --verbose           enable additional output
+      --color TYPE        when to colorize (boolean, always, auto, never, or
+                          debug) (EXPERIMENTAL) (default: never)
       --config CONFIG [+] set/override config option (use 'section.name=value')
       --debug             enable debugging output
       --debugger          start debugger
@@ -884,6 +890,8 @@  Make sure that single '-v' option shows 
                           all prompts
    -q --quiet             suppress output
    -v --verbose           enable additional output
+      --color TYPE        when to colorize (boolean, always, auto, never, or
+                          debug) (EXPERIMENTAL) (default: never)
       --config CONFIG [+] set/override config option (use 'section.name=value')
       --debug             enable debugging output
       --debugger          start debugger
@@ -957,6 +965,8 @@  help options '-v' and '-v -e' should be 
                           all prompts
    -q --quiet             suppress output
    -v --verbose           enable additional output
+      --color TYPE        when to colorize (boolean, always, auto, never, or
+                          debug) (EXPERIMENTAL) (default: never)
       --config CONFIG [+] set/override config option (use 'section.name=value')
       --debug             enable debugging output
       --debugger          start debugger
@@ -991,6 +1001,8 @@  help options '-v' and '-v -e' should be 
                           all prompts
    -q --quiet             suppress output
    -v --verbose           enable additional output
+      --color TYPE        when to colorize (boolean, always, auto, never, or
+                          debug) (EXPERIMENTAL) (default: never)
       --config CONFIG [+] set/override config option (use 'section.name=value')
       --debug             enable debugging output
       --debugger          start debugger
diff -r 1b39bb158cdb -r 25fd71d9347a tests/test-gendoc-ro.t
--- a/tests/test-gendoc-ro.t	Tue Feb 21 17:51:43 2017 +0100
+++ b/tests/test-gendoc-ro.t	Tue Feb 21 18:09:21 2017 +0100
@@ -5,5 +5,5 @@  moving pager to core. These two warnings
 until the localization is corrected.
   $ $TESTDIR/check-gendoc ro
   checking for parse errors
-  gendoc.txt:55: (WARNING/2) Inline interpreted text or phrase reference start-string without end-string.
-  gendoc.txt:55: (WARNING/2) Inline interpreted text or phrase reference start-string without end-string.
+  gendoc.txt:58: (WARNING/2) Inline interpreted text or phrase reference start-string without end-string.
+  gendoc.txt:58: (WARNING/2) Inline interpreted text or phrase reference start-string without end-string.
diff -r 1b39bb158cdb -r 25fd71d9347a tests/test-help.t
--- a/tests/test-help.t	Tue Feb 21 17:51:43 2017 +0100
+++ b/tests/test-help.t	Tue Feb 21 18:09:21 2017 +0100
@@ -316,6 +316,8 @@  Test short command list with verbose opt
                           all prompts
    -q --quiet             suppress output
    -v --verbose           enable additional output
+      --color TYPE        when to colorize (boolean, always, auto, never, or
+                          debug) (EXPERIMENTAL) (default: never)
       --config CONFIG [+] set/override config option (use 'section.name=value')
       --debug             enable debugging output
       --debugger          start debugger
@@ -414,6 +416,8 @@  Verbose help for add
                           all prompts
    -q --quiet             suppress output
    -v --verbose           enable additional output
+      --color TYPE        when to colorize (boolean, always, auto, never, or
+                          debug) (EXPERIMENTAL) (default: never)
       --config CONFIG [+] set/override config option (use 'section.name=value')
       --debug             enable debugging output
       --debugger          start debugger
@@ -2516,6 +2520,9 @@  Dish up an empty repo; serve it cold.
   <td>--verbose</td>
   <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>
+  <tr><td></td>
   <td>--config CONFIG [+]</td>
   <td>set/override config option (use 'section.name=value')</td></tr>
   <tr><td></td>
@@ -2714,6 +2721,9 @@  Dish up an empty repo; serve it cold.
   <td>--verbose</td>
   <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>
+  <tr><td></td>
   <td>--config CONFIG [+]</td>
   <td>set/override config option (use 'section.name=value')</td></tr>
   <tr><td></td>