Mercurial > public > mercurial-scm > hg
diff hgext/color.py @ 10475:2253715fde97
color: don't crash on invalid status codes (issue2036)
If an unknown file with a newline appears in the status output, color
shouldn't raise a KeyError trying to parse second line in the filename.
author | Brodie Rao <me+hg@dackz.net> |
---|---|
date | Sun, 14 Feb 2010 17:08:52 -0500 |
parents | 08a0f04b56bd |
children | 44b4a2a31623 |
line wrap: on
line diff
--- a/hgext/color.py Sun Feb 14 13:28:34 2010 +0100 +++ b/hgext/color.py Sun Feb 14 17:08:52 2010 -0500 @@ -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