changeset 40778:69bd3176da7c

match: raise an Abort error instead of OverflowError This case of OverflowError (one single pattern being too large) has never been properly caught in the past.
author Boris Feld <boris.feld@octobus.net>
date Thu, 22 Nov 2018 17:41:10 +0100
parents 3c842749debc
children e8c992d56465
files mercurial/match.py
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/match.py	Thu Nov 22 21:02:02 2018 +0100
+++ b/mercurial/match.py	Thu Nov 22 17:41:10 2018 +0100
@@ -1201,7 +1201,7 @@
     ... ], '$')
     Traceback (most recent call last):
     ...
-    OverflowError
+    Abort: matcher pattern is too long (20009 bytes)
     """
     try:
         allgroups = []
@@ -1213,7 +1213,8 @@
         for idx, r in enumerate(regexps):
             piecesize = len(r)
             if (piecesize + 4) > MAX_RE_SIZE:
-                raise OverflowError
+                msg = _("matcher pattern is too long (%d bytes)") % piecesize
+                raise error.Abort(msg)
             elif (groupsize + 1 + piecesize) > MAX_RE_SIZE:
                 group = regexps[startidx:idx]
                 allgroups.append(_joinregexes(group))