[PATCH 2 of 2] crecord: throws error instead of crashing for large diffs

Laurent Charignon lcharignon at fb.com
Fri Jul 17 15:52:13 CDT 2015


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1437165841 25200
#      Fri Jul 17 13:44:01 2015 -0700
# Node ID 9b5f1f6e53d7d2efc7830c8a7b896b285c84ae5a
# Parent  67e626be03062910ce3b09c3ef56a1ed9c9ba802
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.

diff --git a/mercurial/crecord.py b/mercurial/crecord.py
--- a/mercurial/crecord.py
+++ b/mercurial/crecord.py
@@ -1609,8 +1609,12 @@ are you sure you want to review/edit and
 
         # 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)


More information about the Mercurial-devel mailing list