crecord: add error reporting for failure in curses interface initialization
authorLaurent Charignon <lcharignon@fb.com>
Fri, 17 Jul 2015 13:41:17 -0700
changeset 25820 701d8c362aa2
parent 25819 be29d26e2949
child 25821 d68544b69736
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.
mercurial/crecord.py
--- 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()