crecord: add mechanism for error reporting
authorLaurent Charignon <lcharignon@fb.com>
Fri, 05 Jun 2015 13:53:49 -0700
changeset 25556 40f0e9e5b821
parent 25555 838fa1932ff8
child 25557 52c552a05414
crecord: add mechanism for error reporting Before this patch, there was no way to report errors in the crecord ui. This patch introduces a new variable errorstr. If set, its content replaces the top banner displayed in crecord until a key is pressed.
mercurial/crecord.py
--- a/mercurial/crecord.py	Fri Jun 05 13:32:52 2015 -0700
+++ b/mercurial/crecord.py	Fri Jun 05 13:53:49 2015 -0700
@@ -511,6 +511,7 @@
 
         self.ui = ui
 
+        self.errorstr = None
         # list of all chunks
         self.chunklist = []
         for h in headerlist:
@@ -976,6 +977,12 @@
 
         # print out the status lines at the top
         try:
+            if self.errorstr is not None:
+                printstring(self.statuswin, self.errorstr, pairname='legend')
+                printstring(self.statuswin, 'Press any key to continue',
+                            pairname='legend')
+                self.statuswin.refresh()
+                return
             printstring(self.statuswin,
                         "SELECT CHUNKS: (j/k/up/dn/pgup/pgdn) move cursor; "
                         "(space/A) toggle hunk/all; (e)dit hunk;",
@@ -1601,6 +1608,9 @@
             self.updatescreen()
             try:
                 keypressed = self.statuswin.getkey()
+                if self.errorstr is not None:
+                    self.errorstr = None
+                    continue
             except curses.error:
                 keypressed = "foobar"
             if self.handlekeypressed(keypressed):