color: minor simplification of some terminfo setup code
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Thu, 22 Dec 2016 13:06:53 +0100
changeset 31086 cf2bc3792ef4
parent 31085 27d3bc0c9093
child 31087 ebd14a4b03fc
color: minor simplification of some terminfo setup code No logic change is introduced. The previous code were using a 'dict.update' with a complex generator. That was a bit confusing to read and not so compact. Instead we now use an explicit loop and conditional for the sake of clarity. This also allow for more simplification coming in the next changeset.
hgext/color.py
--- a/hgext/color.py	Thu Dec 22 06:17:40 2016 +0100
+++ b/hgext/color.py	Thu Dec 22 13:06:53 2016 +0100
@@ -202,14 +202,15 @@
     if mode not in ('auto', 'terminfo'):
         return
 
-    color._terminfo_params.update((key[6:], (False, int(val), ''))
-        for key, val in ui.configitems('color')
-        if key.startswith('color.'))
-    color._terminfo_params.update((key[9:],
-                                   (True, '', val.replace('\\E', '\x1b')))
-        for key, val in ui.configitems('color')
-        if key.startswith('terminfo.'))
+    for key, val in ui.configitems('color'):
+        if key.startswith('color.'):
+            newval = (False, int(val), '')
+            color._terminfo_params[key[6:]] = newval
 
+    for key, val in ui.configitems('color'):
+        if key.startswith('terminfo.'):
+            newval = (True, '', val.replace('\\E', '\x1b'))
+            color._terminfo_params[key[9:]] = newval
     try:
         curses.setupterm()
     except curses.error as e: