[PATCH 2 of 6 V3] match: extract a literal constant into a symbolic one

Boris Feld boris.feld at octobus.net
Fri Nov 23 09:12:45 EST 2018


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1542903632 -3600
#      Thu Nov 22 17:20:32 2018 +0100
# Node ID 8847fda442975010d004dcb0293a40ba70434070
# Parent  917fa088dd67d1f56c751de59acc91abc799d83a
# EXP-Topic perf-ignore
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 8847fda44297
match: extract a literal constant into a symbolic one

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -1184,13 +1184,15 @@ def _buildmatch(kindpats, globsuffix, li
     else:
         return regex, lambda f: any(mf(f) for mf in matchfuncs)
 
+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."""
     try:
         regex = '(?:%s)' % '|'.join([_regex(k, p, globsuffix)
                                      for (k, p, s) in kindpats])
-        if len(regex) > 20000:
+        if len(regex) > MAX_RE_SIZE:
             raise OverflowError
         return regex, _rematcher(regex)
     except OverflowError:


More information about the Mercurial-devel mailing list