[PATCH 3 of 6 V2] match: test for overflow error in pattern

Boris Feld boris.feld at octobus.net
Thu Nov 22 17:17:20 EST 2018


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1542903365 -3600
#      Thu Nov 22 17:16:05 2018 +0100
# Node ID b702174979d09090d5e5081d09755cbb74540ff0
# Parent  7540e746d44775c7098d5fa473be9968317616f1
# EXP-Topic perf-ignore-2
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r b702174979d0
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 @@ MAXRESIZE = 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', '?' * MAXRESIZE, '')
+    ... ], '$')
+    Traceback (most recent call last):
+    ...
+    OverflowError
+    """
     try:
         regex = '(?:%s)' % '|'.join([_regex(k, p, globsuffix)
                                      for (k, p, s) in kindpats])


More information about the Mercurial-devel mailing list