[PATCH 4 of 7] match: explode if unsupported pattern passed down to _regex() builder

Yuya Nishihara yuya at tcha.org
Thu Jul 5 10:14:29 EDT 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1528613278 -32400
#      Sun Jun 10 15:47:58 2018 +0900
# Node ID eca5e10e8949810dc00b01bc84566393bba2bfae
# Parent  0b3716e343fed24d4d921f5936e9db2837e9ca33
match: explode if unsupported pattern passed down to _regex() builder

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -819,7 +819,9 @@ def _regex(kind, pat, globsuffix):
         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.


More information about the Mercurial-devel mailing list