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

login
register
mail settings
Submitter Yuya Nishihara
Date July 5, 2018, 2:14 p.m.
Message ID <eca5e10e8949810dc00b.1530800069@mimosa>
Download mbox | patch
Permalink /patch/32644/
State New
Headers show

Comments

Yuya Nishihara - July 5, 2018, 2:14 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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

Patch

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.