match: extract a literal constant into a symbolic one
authorBoris Feld <boris.feld@octobus.net>
Thu, 22 Nov 2018 17:20:32 +0100
changeset 40774 8306dac48061
parent 40773 0605726179a0
child 40775 4e02f25f31c6
match: extract a literal constant into a symbolic one
mercurial/match.py
--- a/mercurial/match.py	Sat Dec 01 21:42:48 2018 -0500
+++ b/mercurial/match.py	Thu Nov 22 17:20:32 2018 +0100
@@ -1184,13 +1184,15 @@
     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:
             return regex, _rematcher(regex)
         # We're using a Python with a tiny regex engine and we
         # made it explode, so we'll divide the pattern list in two