Patchwork [stable] color: don't fail on error messages when no curses (issue4237)

login
register
mail settings
Submitter Mads Kiilerich
Date May 3, 2014, 1:30 a.m.
Message ID <d8e541e3782b7b6cd119.1399080603@localhost.localdomain>
Download mbox | patch
Permalink /patch/4583/
State Accepted
Commit 75aaae8ad6600c333e8b24492f3970eb1417138e
Headers show

Comments

Mads Kiilerich - May 3, 2014, 1:30 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1399080570 -7200
#      Sat May 03 03:29:30 2014 +0200
# Branch stable
# Node ID d8e541e3782b7b6cd11910320ed48a2f67770f58
# Parent  cadad384c97c7956c98f3c9b92d8cc40fa16d93b
color: don't fail on error messages when no curses (issue4237)

The error only occured when Python didn't have curses - such as on Windows and
when Python was built without curses support.

No curses can also be emulated by (re)moving .../lib/python2.7/curses/ from the
Python installation.

It is left as an exercise to figure out exactly what changed in Mercurial that
triggered this error.
Sean Farley - May 3, 2014, 1:38 a.m.
Mads Kiilerich <mads@kiilerich.com> writes:

> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1399080570 -7200
> #      Sat May 03 03:29:30 2014 +0200
> # Branch stable
> # Node ID d8e541e3782b7b6cd11910320ed48a2f67770f58
> # Parent  cadad384c97c7956c98f3c9b92d8cc40fa16d93b
> color: don't fail on error messages when no curses (issue4237)

I was finally able to reproduce this on windows and can confirm this
fixes the issue.
Pierre-Yves David - May 5, 2014, 11:55 p.m.
On 05/02/2014 06:30 PM, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1399080570 -7200
> #      Sat May 03 03:29:30 2014 +0200
> # Branch stable
> # Node ID d8e541e3782b7b6cd11910320ed48a2f67770f58
> # Parent  cadad384c97c7956c98f3c9b92d8cc40fa16d93b
> color: don't fail on error messages when no curses (issue4237)

This patch have been queued to the clowncopter, Thanks!

<regular grumbling about reporting that during the 3.0-rc cycle>

Patch

diff --git a/hgext/color.py b/hgext/color.py
--- a/hgext/color.py
+++ b/hgext/color.py
@@ -230,7 +230,7 @@  try:
                         'cyan': (False, curses.COLOR_CYAN),
                         'white': (False, curses.COLOR_WHITE)}
 except ImportError:
-    _terminfo_params = False
+    _terminfo_params = {}
 
 _styles = {'grep.match': 'red bold',
            'grep.linenumber': 'green',
diff --git a/tests/test-status-color.t b/tests/test-status-color.t
--- a/tests/test-status-color.t
+++ b/tests/test-status-color.t
@@ -319,4 +319,17 @@  hg resolve with one unresolved, one reso
   \x1b[0;31;1mU a\x1b[0m (esc)
   \x1b[0;32;1mR b\x1b[0m (esc)
 
+color coding of error message with current availability of curses
+
+  $ hg unknowncommand > /dev/null
+  hg: unknown command 'unknowncommand'
+  [255]
+
+color coding of error message without curses
+
+  $ echo 'raise ImportError' > curses.py
+  $ PYTHONPATH=`pwd`:$PYTHONPATH hg unknowncommand > /dev/null
+  hg: unknown command 'unknowncommand'
+  [255]
+
   $ cd ..