From patchwork Thu Nov 22 22:17:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [6,of,6,V2] match: raise an Abort error instead of OverflowError From: Boris Feld X-Patchwork-Id: 36728 Message-Id: <0f01e9775b9732270e22.1542925043@localhost.localdomain> To: mercurial-devel@mercurial-scm.org Date: Thu, 22 Nov 2018 23:17:23 +0100 # HG changeset patch # User Boris Feld # Date 1542904870 -3600 # Thu Nov 22 17:41:10 2018 +0100 # Node ID 0f01e9775b9732270e22dd899465c09e832e612e # Parent 018578f3ab597d5ea573107e7310470de76a3907 # EXP-Topic perf-ignore-2 # Available At https://bitbucket.org/octobus/mercurial-devel/ # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 0f01e9775b97 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) > MAXRESIZE: - raise OverflowError + msg = _("matcher pattern is too long (%d bytes)") % piecesize + raise error.Abort(msg) elif (groupsize + 1 + piecesize) > MAXRESIZE: group = regexps[startidx:idx] allgroups.append(_groupregexps(group))