Patchwork [1,of,8,simple] color: spread '_effect' values for readability

login
register
mail settings
Submitter Pierre-Yves David
Date Feb. 15, 2017, 11:06 a.m.
Message ID <42d4b49b39d687906520.1487156773@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/18502/
State Accepted
Delegated to: Martin von Zweigbergk
Headers show

Comments

Pierre-Yves David - Feb. 15, 2017, 11:06 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1479491019 -3600
#      Fri Nov 18 18:43:39 2016 +0100
# Node ID 42d4b49b39d6879065209ea3ca71f1e3fa88fcbc
# Parent  354020079723e02ad6db68f58ef26eb7ebd005a8
# EXP-Topic color
color: spread '_effect' values for readability

We move to our "usual" one value per line style.
via Mercurial-devel - Feb. 15, 2017, 8:49 p.m.
On Wed, Feb 15, 2017 at 3:06 AM, Pierre-Yves David
<pierre-yves.david@ens-lyon.org> wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
> # Date 1479491019 -3600
> #      Fri Nov 18 18:43:39 2016 +0100
> # Node ID 42d4b49b39d6879065209ea3ca71f1e3fa88fcbc
> # Parent  354020079723e02ad6db68f58ef26eb7ebd005a8
> # EXP-Topic color
> color: spread '_effect' values for readability
>
> We move to our "usual" one value per line style.

Nit: the even more usual style (by a factor 2-2.5, it seems) is to put
the values on separate lines from the curly braces. But I won't let
that stop the patch, of course.

>
> diff -r 354020079723 -r 42d4b49b39d6 hgext/color.py
> --- a/hgext/color.py    Tue Feb 07 17:33:35 2017 +0100
> +++ b/hgext/color.py    Fri Nov 18 18:43:39 2016 +0100
> @@ -187,13 +187,28 @@ command = cmdutil.command(cmdtable)
>  testedwith = 'ships-with-hg-core'
>
>  # start and stop parameters for effects
> -_effects = {'none': 0, 'black': 30, 'red': 31, 'green': 32, 'yellow': 33,
> -            'blue': 34, 'magenta': 35, 'cyan': 36, 'white': 37, 'bold': 1,
> -            'italic': 3, 'underline': 4, 'inverse': 7, 'dim': 2,
> -            'black_background': 40, 'red_background': 41,
> -            'green_background': 42, 'yellow_background': 43,
> -            'blue_background': 44, 'purple_background': 45,
> -            'cyan_background': 46, 'white_background': 47}
> +_effects = {'none': 0,
> +            'black': 30,
> +            'red': 31,
> +            'green': 32,
> +            'yellow': 33,
> +            'blue': 34,
> +            'magenta': 35,
> +            'cyan': 36,
> +            'white': 37,
> +            'bold': 1,
> +            'italic': 3,
> +            'underline': 4,
> +            'inverse': 7,
> +            'dim': 2,
> +            'black_background': 40,
> +            'red_background': 41,
> +            'green_background': 42,
> +            'yellow_background': 43,
> +            'blue_background': 44,
> +            'purple_background': 45,
> +            'cyan_background': 46,
> +            'white_background': 47}
>
>  def _terminfosetup(ui, mode):
>      '''Initialize terminfo data and the terminal if we're in terminfo mode.'''
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Pierre-Yves David - Feb. 16, 2017, 9:06 a.m.
On 02/15/2017 09:49 PM, Martin von Zweigbergk wrote:
> On Wed, Feb 15, 2017 at 3:06 AM, Pierre-Yves David
> <pierre-yves.david@ens-lyon.org> wrote:
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
>> # Date 1479491019 -3600
>> #      Fri Nov 18 18:43:39 2016 +0100
>> # Node ID 42d4b49b39d6879065209ea3ca71f1e3fa88fcbc
>> # Parent  354020079723e02ad6db68f58ef26eb7ebd005a8
>> # EXP-Topic color
>> color: spread '_effect' values for readability
>>
>> We move to our "usual" one value per line style.
>
> Nit: the even more usual style (by a factor 2-2.5, it seems) is to put
> the values on separate lines from the curly braces. But I won't let
> that stop the patch, of course.

Just ot be sure, You mean:

_effects = {
     'none': 0,
     black': 30,
}

Right?
via Mercurial-devel - Feb. 16, 2017, 2:39 p.m.
On Feb 16, 2017 01:06, "Pierre-Yves David" <pierre-yves.david@ens-lyon.org>
wrote:



On 02/15/2017 09:49 PM, Martin von Zweigbergk wrote:

> On Wed, Feb 15, 2017 at 3:06 AM, Pierre-Yves David
> <pierre-yves.david@ens-lyon.org> wrote:
>
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
>> # Date 1479491019 -3600
>> #      Fri Nov 18 18:43:39 2016 +0100
>> # Node ID 42d4b49b39d6879065209ea3ca71f1e3fa88fcbc
>> # Parent  354020079723e02ad6db68f58ef26eb7ebd005a8
>> # EXP-Topic color
>> color: spread '_effect' values for readability
>>
>> We move to our "usual" one value per line style.
>>
>
> Nit: the even more usual style (by a factor 2-2.5, it seems) is to put
> the values on separate lines from the curly braces. But I won't let
> that stop the patch, of course.
>

Just ot be sure, You mean:


_effects = {
    'none': 0,
    black': 30,
}

Right?


Exactly. With the closing brace like that too (but a few were different).
That's also my preferred form, which is probably why I even noticed.

That seemed to be more common if I was grepping right. But your form was
used consistently (?) in color.py, so that was probably the right choice in
this case anyway.

Patch

diff -r 354020079723 -r 42d4b49b39d6 hgext/color.py
--- a/hgext/color.py	Tue Feb 07 17:33:35 2017 +0100
+++ b/hgext/color.py	Fri Nov 18 18:43:39 2016 +0100
@@ -187,13 +187,28 @@  command = cmdutil.command(cmdtable)
 testedwith = 'ships-with-hg-core'
 
 # start and stop parameters for effects
-_effects = {'none': 0, 'black': 30, 'red': 31, 'green': 32, 'yellow': 33,
-            'blue': 34, 'magenta': 35, 'cyan': 36, 'white': 37, 'bold': 1,
-            'italic': 3, 'underline': 4, 'inverse': 7, 'dim': 2,
-            'black_background': 40, 'red_background': 41,
-            'green_background': 42, 'yellow_background': 43,
-            'blue_background': 44, 'purple_background': 45,
-            'cyan_background': 46, 'white_background': 47}
+_effects = {'none': 0,
+            'black': 30,
+            'red': 31,
+            'green': 32,
+            'yellow': 33,
+            'blue': 34,
+            'magenta': 35,
+            'cyan': 36,
+            'white': 37,
+            'bold': 1,
+            'italic': 3,
+            'underline': 4,
+            'inverse': 7,
+            'dim': 2,
+            'black_background': 40,
+            'red_background': 41,
+            'green_background': 42,
+            'yellow_background': 43,
+            'blue_background': 44,
+            'purple_background': 45,
+            'cyan_background': 46,
+            'white_background': 47}
 
 def _terminfosetup(ui, mode):
     '''Initialize terminfo data and the terminal if we're in terminfo mode.'''