changeset 8945:7b3d837ca60e

color: don't blow up if configured with unknown color (just warn).
author Greg Ward <greg-hg@gerg.ca>
date Thu, 25 Jun 2009 09:23:33 -0400
parents dda4ad7c9ea9
children 576623f95972
files hgext/color.py tests/test-status-color tests/test-status-color.out
diffstat 3 files changed, 22 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/color.py	Wed Jun 24 19:20:59 2009 +0200
+++ b/hgext/color.py	Thu Jun 25 09:23:33 2009 -0400
@@ -261,6 +261,15 @@
     ])
 
     for status in effectsmap:
-        effects = ui.configlist('color', cmd + '.' + status)
+        configkey = cmd + '.' + status
+        effects = ui.configlist('color', configkey)
         if effects:
-            effectsmap[status] = effects
+            good = []
+            for e in effects:
+                if e in _effect_params:
+                    good.append(e)
+                else:
+                    ui.warn(_("ignoring unknown color/effect %r "
+                              "(configured in color.%s)\n")
+                            % (e, configkey))
+            effectsmap[status] = good
--- a/tests/test-status-color	Wed Jun 24 19:20:59 2009 +0200
+++ b/tests/test-status-color	Thu Jun 25 09:23:33 2009 -0400
@@ -61,6 +61,9 @@
 rm deleted
 hg copy modified copied
 
+echo "% test unknown color"
+hg --config color.status.modified=periwinkle status --color=always
+
 # Run status with 2 different flags.
 # Check if result is the same or different.
 # If result is not as expected, raise error
--- a/tests/test-status-color.out	Wed Jun 24 19:20:59 2009 +0200
+++ b/tests/test-status-color.out	Thu Jun 25 09:23:33 2009 -0400
@@ -124,3 +124,11 @@
 adding deleted
 adding modified
 adding removed
+% test unknown color
+ignoring unknown color/effect 'periwinkle' (configured in color.status.modified)
+M modified
+A added
+A copied
+R removed
+! deleted
+? unknown