changeset 25820:701d8c362aa2

crecord: add error reporting for failure in curses interface initialization Before this patch, we couldn't report to the user any error that occurred: - after we enabled the curses interface but - before the interface is set up and drawn This patch, provides a way to set errors that happens during the initialization of the interface and log them once the curses interface has been displayed.
author Laurent Charignon <lcharignon@fb.com>
date Fri, 17 Jul 2015 13:41:17 -0700
parents be29d26e2949
children d68544b69736
files mercurial/crecord.py
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/crecord.py	Sun Jul 05 12:15:54 2015 +0900
+++ b/mercurial/crecord.py	Fri Jul 17 13:41:17 2015 -0700
@@ -484,6 +484,8 @@
     chunkselector = curseschunkselector(headerlist, ui)
     f = signal.getsignal(signal.SIGTSTP)
     curses.wrapper(chunkselector.main)
+    if chunkselector.initerr is not None:
+        raise util.Abort(chunkselector.initerr)
     # ncurses does not restore signal handler for SIGTSTP
     signal.signal(signal.SIGTSTP, f)
 
@@ -1582,6 +1584,9 @@
         """
         signal.signal(signal.SIGWINCH, self.sigwinchhandler)
         self.stdscr = stdscr
+        # error during initialization, cannot be printed in the curses
+        # interface, it should be printed by the calling code
+        self.initerr = None
         self.yscreensize, self.xscreensize = self.stdscr.getmaxyx()
 
         curses.start_color()