match: raise an Abort error instead of OverflowError
authorBoris Feld <boris.feld@octobus.net>
Thu, 22 Nov 2018 17:41:10 +0100
changeset 40778 69bd3176da7c
parent 40777 3c842749debc
child 40779 e8c992d56465
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.
mercurial/match.py
--- 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))