changeset 25821:d68544b69736

crecord: throws error instead of crashing for large diffs Before this patch, crecord was crashing for large diffs (30k lines on my laptop). This patch catches the exception raised in that case and use the error reporting mechanism introduced in the previous patch for notifying the user of the issue. It is not possible to add a test for that for now as we don't yet have full blown ui tests for the curses interface.
author Laurent Charignon <lcharignon@fb.com>
date Fri, 17 Jul 2015 13:44:01 -0700
parents 701d8c362aa2
children 00e3f909907f
files mercurial/crecord.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/crecord.py	Fri Jul 17 13:41:17 2015 -0700
+++ b/mercurial/crecord.py	Fri Jul 17 13:44:01 2015 -0700
@@ -1612,8 +1612,12 @@
 
         # add 1 so to account for last line text reaching end of line
         self.numpadlines = self.getnumlinesdisplayed(ignorefolding=True) + 1
-        self.chunkpad = curses.newpad(self.numpadlines, self.xscreensize)
 
+        try:
+            self.chunkpad = curses.newpad(self.numpadlines, self.xscreensize)
+        except curses.error:
+            self.initerr = _('this diff is too large to be displayed')
+            return
         # initialize selecteitemendline (initial start-line is 0)
         self.selecteditemendline = self.getnumlinesdisplayed(
             self.currentselecteditem, recursechildren=False)