[PATCH STABLE] color: don't crash on invalid status codes (issue2036)
Benoit Boissinot
benoit.boissinot at ens-lyon.org
Sun Feb 14 21:56:07 UTC 2010
On Sun, Feb 14, 2010 at 04:15:27PM -0500, Brodie Rao wrote:
> # HG changeset patch
> # User Brodie Rao <me+hg at dackz.net>
> # Date 1266182042 18000
> # Branch stable
> # Node ID 1bfe425ee57ac88f53a66f0df560b3f308ccdf0c
> # Parent 634b0e7561eca044e37ac9643578f1c044eec64d
> 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.
>
> diff --git a/hgext/color.py b/hgext/color.py
> --- a/hgext/color.py
> +++ b/hgext/color.py
> @@ -117,10 +117,14 @@ def _colorstatuslike(abbreviations, effe
>
> # 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:
Maybe just add a comment to explain what happens, otherwise the code
might be a bit puzzling ;)
thanks,
Benoit
--
:wq
More information about the Mercurial-devel
mailing list