[PATCH 2 of 3] crecord: add mechanism for error reporting

Laurent Charignon lcharignon at fb.com
Fri Jun 5 16:03:32 CDT 2015


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1433537629 25200
#      Fri Jun 05 13:53:49 2015 -0700
# Node ID 82711472302682face294f925835780ab9f710a8
# Parent  a0318381fde8e05a9e52c090757855a6a962a61f
crecord: add mechanism for error reporting

Before this patch there was no way to report error 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.

diff --git a/mercurial/crecord.py b/mercurial/crecord.py
--- a/mercurial/crecord.py
+++ b/mercurial/crecord.py
@@ -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,8 @@
             self.updatescreen()
             try:
                 keypressed = self.statuswin.getkey()
+                if self.errorstr is not None:
+                    self.errorstr = None
             except curses.error:
                 keypressed = "foobar"
             if self.handlekeypressed(keypressed):


More information about the Mercurial-devel mailing list