[PATCH 5 of 5 V4] match: raise an Abort error instead of OverflowError

Boris Feld boris.feld at octobus.net
Sat Dec 1 07:07:35 EST 2018


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1542904870 -3600
#      Thu Nov 22 17:41:10 2018 +0100
# Node ID fb26ffdf255f07c57f6b18f31f8b146e9f86bd72
# Parent  0a28ff17100a67c21a99ef363f15aef09e4dfa8b
# EXP-Topic perf-ignore
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r fb26ffdf255f
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.

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -1201,7 +1201,7 @@ def _buildregexmatch(kindpats, globsuffi
     ... ], '$')
     Traceback (most recent call last):
     ...
-    OverflowError
+    Abort: matcher pattern is too long (20009 bytes)
     """
     try:
         allgroups = []
@@ -1213,7 +1213,8 @@ def _buildregexmatch(kindpats, globsuffi
         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))


More information about the Mercurial-devel mailing list