[PATCH] color: don't blow up if configured with unknown color (just warn)
Greg Ward
greg-hg at gerg.ca
Thu Jun 25 08:23:55 CDT 2009
# HG changeset patch
# User Greg Ward <greg-hg at gerg.ca>
# Date 1245936213 14400
# Node ID af67057f471c91982b13385f8e1e1949316f7068
# Parent 5e6a6fb10a77f1a55e0f9acd49ee5aea6004dc78
color: don't blow up if configured with unknown color (just warn).
diff --git a/hgext/color.py b/hgext/color.py
--- a/hgext/color.py
+++ b/hgext/color.py
@@ -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
diff --git a/tests/test-status-color b/tests/test-status-color
--- a/tests/test-status-color
+++ b/tests/test-status-color
@@ -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
diff --git a/tests/test-status-color.out b/tests/test-status-color.out
--- a/tests/test-status-color.out
+++ b/tests/test-status-color.out
@@ -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
+[0;32;1mA added[0m
+[0;32;1mA copied[0m
+[0;31;1mR removed[0m
+[0;36;1;4m! deleted[0m
+[0;35;1;4m? unknown[0m
More information about the Mercurial-devel
mailing list