[PATCH 2 of 6 V2] match: extract a literal constant into a symbolic one
Boris Feld
boris.feld at octobus.net
Thu Nov 22 22:17:19 UTC 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 7540e746d44775c7098d5fa473be9968317616f1
# Parent 98300756a74d424fcd1510b0bb98f07b9b0f8663
# EXP-Topic perf-ignore-2
# Available At https://bitbucket.org/octobus/mercurial-devel/
# hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 7540e746d447
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)
+MAXRESIZE = 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) > MAXRESIZE:
raise OverflowError
return regex, _rematcher(regex)
except OverflowError:
More information about the Mercurial-devel
mailing list