# HG changeset patch # User Boris Feld # Date 2018-11-22 16:16:05 # Node ID 4e02f25f31c6b4472eb0a9b0f8bba538a3dd4b09 # Parent 8306dac4806156bf05729c5a79f24120855f09cd match: test for overflow error in pattern If a single pattern is too large to handle, we raise an exception. This case is now doctested. diff --git a/mercurial/match.py b/mercurial/match.py --- a/mercurial/match.py +++ b/mercurial/match.py @@ -1188,7 +1188,16 @@ MAX_RE_SIZE = 20000 def _buildregexmatch(kindpats, globsuffix): """Build a match function from a list of kinds and kindpats, - return regexp string and a matcher function.""" + return regexp string and a matcher function. + + Test too large input + >>> _buildregexmatch([ + ... ('relglob', '?' * MAX_RE_SIZE, '') + ... ], '$') + Traceback (most recent call last): + ... + OverflowError + """ try: regex = '(?:%s)' % '|'.join([_regex(k, p, globsuffix) for (k, p, s) in kindpats])