hgext/color.py
branchstable
changeset 10477 44b4a2a31623
parent 10463 5ddde896a19d
parent 10475 2253715fde97
child 10826 717c35d55fb3
child 11182 3c368a1c962d
--- a/hgext/color.py	Mon Feb 15 00:12:10 2010 +0100
+++ b/hgext/color.py	Mon Feb 15 00:14:16 2010 +0100
@@ -117,10 +117,16 @@
 
     # apply color to output and display it
     for i in xrange(len(lines)):
-        status = abbreviations[lines_with_status[i][0]]
-        effects = effectdefs[status]
-        if effects:
-            lines[i] = render_effects(lines[i], effects)
+        try:
+            status = abbreviations[lines_with_status[i][0]]
+        except KeyError:
+            # Ignore lines with invalid codes, especially in the case of
+            # of unknown filenames containing newlines (issue2036).
+            pass
+        else:
+            effects = effectdefs[status]
+            if effects:
+                lines[i] = render_effects(lines[i], effects)
         ui.write(lines[i] + delimiter)
     return retval