# Patchwork [5,of,6] color: minor reversal of two conditional clause for clarity

Submitter Pierre-Yves David Feb. 21, 2017, 10:18 p.m. <2278337558dfe55dc11d.1487715481@nodosa.octopoid.net> mbox | patch /patch/18697/ Accepted show

Pierre-Yves David - Feb. 21, 2017, 10:18 p.m.
```# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1482409152 -3600
#      Thu Dec 22 13:19:12 2016 +0100
# Node ID 2278337558dfe55dc11db33654bff351c9a8ee2e
# EXP-Topic color
color: minor reversal of two conditional clause for clarity

Another minor cleanup while reading the code. The two branches of the conditional
have similar complexity so we go for the order that give us the simplest
condition (we drop the negation).
```

## Patch

```diff -r 1f69891d7e7a -r 2278337558df mercurial/color.py
--- a/mercurial/color.py	Thu Feb 16 10:52:27 2017 +0100
+++ b/mercurial/color.py	Thu Dec 22 13:19:12 2016 +0100
@@ -165,14 +165,14 @@  def _render_effects(text, effects):
'Wrap text in commands to turn on each effect.'
if not text:
return text
-    if not _terminfo_params:
+    if _terminfo_params:
+        start = ''.join(_effect_str(effect)
+                        for effect in ['none'] + effects.split())
+        stop = _effect_str('none')
+    else:
start = [str(_effects[e]) for e in ['none'] + effects.split()]
start = '\033[' + ';'.join(start) + 'm'
stop = '\033[' + str(_effects['none']) + 'm'
-    else:
-        start = ''.join(_effect_str(effect)
-                        for effect in ['none'] + effects.split())
-        stop = _effect_str('none')
return ''.join([start, text, stop])

w32effects = None

```