changeset 40809:4e02f25f31c6

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.
author Boris Feld <boris.feld@octobus.net>
date Thu, 22 Nov 2018 17:16:05 +0100
parents 8306dac48061
children ce401300f981
files mercurial/match.py
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/match.py	Thu Nov 22 17:20:32 2018 +0100
+++ b/mercurial/match.py	Thu Nov 22 17:16:05 2018 +0100
@@ -1188,7 +1188,16 @@
 
 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])