##// END OF EJS Templates
fileset: do not traceback on invalid grep pattern
Patrick Mezard -
r17368:01cc267f stable
parent child Browse files
Show More
@@ -256,8 +256,11 b' def grep(mctx, x):'
256 """``grep(regex)``
256 """``grep(regex)``
257 File contains the given regular expression.
257 File contains the given regular expression.
258 """
258 """
259 pat = getstring(x, _("grep requires a pattern"))
259 try:
260 r = re.compile(pat)
260 # i18n: "grep" is a keyword
261 r = re.compile(getstring(x, _("grep requires a pattern")))
262 except re.error, e:
263 raise error.ParseError(_('invalid match pattern: %s') % e)
261 return [f for f in mctx.existing() if r.search(mctx.ctx[f].data())]
264 return [f for f in mctx.existing() if r.search(mctx.ctx[f].data())]
262
265
263 _units = dict(k=2**10, K=2**10, kB=2**10, KB=2**10,
266 _units = dict(k=2**10, K=2**10, kB=2**10, KB=2**10,
@@ -89,3 +89,11 b' Test files properties'
89 $ fileset 'binary()'
89 $ fileset 'binary()'
90 bin
90 bin
91
91
92 $ fileset 'grep("b{1}")'
93 b2
94 c1
95 b1
96 $ fileset 'grep("missingparens(")'
97 hg: parse error: invalid match pattern: unbalanced parenthesis
98 [255]
99
General Comments 0
You need to be logged in to leave comments. Login now