mercurial/match.py
changeset 40775 4e02f25f31c6
parent 40774 8306dac48061
child 40776 ce401300f981
equal deleted inserted replaced
40774:8306dac48061 40775:4e02f25f31c6
  1186 
  1186 
  1187 MAX_RE_SIZE = 20000
  1187 MAX_RE_SIZE = 20000
  1188 
  1188 
  1189 def _buildregexmatch(kindpats, globsuffix):
  1189 def _buildregexmatch(kindpats, globsuffix):
  1190     """Build a match function from a list of kinds and kindpats,
  1190     """Build a match function from a list of kinds and kindpats,
  1191     return regexp string and a matcher function."""
  1191     return regexp string and a matcher function.
       
  1192 
       
  1193     Test too large input
       
  1194     >>> _buildregexmatch([
       
  1195     ...     ('relglob', '?' * MAX_RE_SIZE, '')
       
  1196     ... ], '$')
       
  1197     Traceback (most recent call last):
       
  1198     ...
       
  1199     OverflowError
       
  1200     """
  1192     try:
  1201     try:
  1193         regex = '(?:%s)' % '|'.join([_regex(k, p, globsuffix)
  1202         regex = '(?:%s)' % '|'.join([_regex(k, p, globsuffix)
  1194                                      for (k, p, s) in kindpats])
  1203                                      for (k, p, s) in kindpats])
  1195         if len(regex) <= MAX_RE_SIZE:
  1204         if len(regex) <= MAX_RE_SIZE:
  1196             return regex, _rematcher(regex)
  1205             return regex, _rematcher(regex)