Patchwork color: add parenthesis to help readability

login
register
mail settings
Submitter Pierre-Yves David
Date June 2, 2014, 7:50 p.m.
Message ID <44ded2121b08d82636c9.1401738613@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/4914/
State Accepted
Commit 3094925279f980a9048881192f0f913fcc95e70a
Headers show

Comments

Pierre-Yves David - June 2, 2014, 7:50 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1401474528 25200
#      Fri May 30 11:28:48 2014 -0700
# Node ID 44ded2121b08d82636c922a42f2befb7bb17605c
# Parent  25732fab4dc35a76cfb8f659fde48c7e0dc42dbf
color: add parenthesis to help readability

Took me a multiple attempts until my mind eventually stop reading:

  auto = coloropt = 'auto'

And properly reads:

  auto = colorpopt == 'auto'

So we add parenthesis to clarify.
Augie Fackler - June 7, 2014, 1:38 p.m.
On Mon, Jun 02, 2014 at 12:50:13PM -0700, pierre-yves.david@ens-lyon.org wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1401474528 25200
> #      Fri May 30 11:28:48 2014 -0700
> # Node ID 44ded2121b08d82636c922a42f2befb7bb17605c
> # Parent  25732fab4dc35a76cfb8f659fde48c7e0dc42dbf
> color: add parenthesis to help readability

Righteous. Queued.

>
> Took me a multiple attempts until my mind eventually stop reading:
>
>   auto = coloropt = 'auto'
>
> And properly reads:
>
>   auto = colorpopt == 'auto'
>
> So we add parenthesis to clarify.
>
> diff --git a/hgext/color.py b/hgext/color.py
> --- a/hgext/color.py
> +++ b/hgext/color.py
> @@ -166,11 +166,11 @@ def _terminfosetup(ui, mode):
>          _terminfo_params = {}
>
>  def _modesetup(ui, coloropt):
>      global _terminfo_params
>
> -    auto = coloropt == 'auto'
> +    auto = (coloropt == 'auto')
>      always = not auto and util.parsebool(coloropt)
>      if not always and not auto:
>          return None
>
>      formatted = always or (os.environ.get('TERM') != 'dumb' and ui.formatted())
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/hgext/color.py b/hgext/color.py
--- a/hgext/color.py
+++ b/hgext/color.py
@@ -166,11 +166,11 @@  def _terminfosetup(ui, mode):
         _terminfo_params = {}
 
 def _modesetup(ui, coloropt):
     global _terminfo_params
 
-    auto = coloropt == 'auto'
+    auto = (coloropt == 'auto')
     always = not auto and util.parsebool(coloropt)
     if not always and not auto:
         return None
 
     formatted = always or (os.environ.get('TERM') != 'dumb' and ui.formatted())