match: explode if unsupported pattern passed down to _regex() builder
authorYuya Nishihara <yuya@tcha.org>
Sun, 10 Jun 2018 15:47:58 +0900
changeset 46863 2d487b9cac0729d5911af6ff02bed86cca3e29ad
parent 46862 76838305b9dd2ed2d0e9f4feb94ca68c39456b28
child 46864 ec0cee4c1fff356c903bc03bed169eeb9fca5317
push id826
push usergszorc@mozilla.com
push dateSun, 08 Jul 2018 00:11:10 +0000
match: explode if unsupported pattern passed down to _regex() builder
mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -814,17 +814,19 @@ def _regex(kind, pat, globsuffix):
         # Anything after the pattern must be a non-directory.
         return escaped + '[^/]+$'
     if kind == 'relglob':
         return '(?:|.*/)' + _globre(pat) + globsuffix
     if kind == 'relre':
         if pat.startswith('^'):
             return pat
         return '.*' + pat
-    return _globre(pat) + globsuffix
+    if kind == 'glob':
+        return _globre(pat) + globsuffix
+    raise error.ProgrammingError('not a regex pattern: %s:%s' % (kind, pat))
 
 def _buildmatch(ctx, kindpats, globsuffix, listsubrepos, root):
     '''Return regexp string and a matcher function for kindpats.
     globsuffix is appended to the regexp of globs.'''
     matchfuncs = []
 
     subincludes, kindpats = _expandsubinclude(kindpats, root)
     if subincludes: