changeset 35528:fb2e59e92651

crecord: fallback to color = no when curses.use_default_colors() fails Even when python was setup/compiled with curses, curses.use_default_colors() may raise a curses exception when the TERM environment variable specifies a value where no propper color configuration is possible. This patch falls back to non-color mode to let the user continue instead of failing with an unhandled exception.
author Elmar Bartel <elb_hg@leo.org>
date Thu, 04 Jan 2018 12:34:40 +0100
parents f43dc62cfe11
children 5afe0ca59b07
files mercurial/crecord.py
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/crecord.py	Thu Jan 04 12:12:07 2018 +0100
+++ b/mercurial/crecord.py	Thu Jan 04 12:34:40 2018 +0100
@@ -1719,7 +1719,10 @@
         self.yscreensize, self.xscreensize = self.stdscr.getmaxyx()
 
         curses.start_color()
-        curses.use_default_colors()
+        try:
+            curses.use_default_colors()
+        except curses.error:
+            self.usecolor = False
 
         # available colors: black, blue, cyan, green, magenta, white, yellow
         # init_pair(color_id, foreground_color, background_color)