# HG changeset patch # User Boris Feld # Date 1542903949 -3600 # Node ID ce401300f981330db9fe95124ec84b3595468d21 # Parent 4e02f25f31c6b4472eb0a9b0f8bba538a3dd4b09 match: extract function that group regexps diff -r 4e02f25f31c6 -r ce401300f981 mercurial/match.py --- a/mercurial/match.py Thu Nov 22 17:16:05 2018 +0100 +++ b/mercurial/match.py Thu Nov 22 17:25:49 2018 +0100 @@ -1186,6 +1186,10 @@ MAX_RE_SIZE = 20000 +def _joinregexes(regexps): + """gather multiple regular expressions into a single one""" + return '(?:%s)' % '|'.join(regexps) + def _buildregexmatch(kindpats, globsuffix): """Build a match function from a list of kinds and kindpats, return regexp string and a matcher function. @@ -1199,7 +1203,7 @@ OverflowError """ try: - regex = '(?:%s)' % '|'.join([_regex(k, p, globsuffix) + regex = _joinregexes([_regex(k, p, globsuffix) for (k, p, s) in kindpats]) if len(regex) <= MAX_RE_SIZE: return regex, _rematcher(regex)