##// END OF EJS Templates
fileset: add grep predicate
Matt Mackall -
r14682:8785fd75 default
parent child Browse files
Show More
@@ -5,7 +5,7 b''
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 import parser, error, util, merge
8 import parser, error, util, merge, re
9 from i18n import _
9 from i18n import _
10
10
11 elements = {
11 elements = {
@@ -235,12 +235,21 b' def hgignore(mctx, x):'
235 ignore = mctx.ctx._repo.dirstate._ignore
235 ignore = mctx.ctx._repo.dirstate._ignore
236 return [f for f in mctx.subset if ignore(f)]
236 return [f for f in mctx.subset if ignore(f)]
237
237
238 def grep(mctx, x):
239 """``grep(regex)``
240 File contains the given regular expression.
241 """
242 pat = getstring(x, _("grep requires a pattern"))
243 r = re.compile(pat)
244 return [f for f in mctx.subset if r.search(mctx.ctx[f].data())]
245
238 symbols = {
246 symbols = {
239 'added': added,
247 'added': added,
240 'binary': binary,
248 'binary': binary,
241 'clean': clean,
249 'clean': clean,
242 'deleted': deleted,
250 'deleted': deleted,
243 'exec': exec_,
251 'exec': exec_,
252 'grep': grep,
244 'ignored': ignored,
253 'ignored': ignored,
245 'hgignore': hgignore,
254 'hgignore': hgignore,
246 'modified': modified,
255 'modified': modified,
General Comments 0
You need to be logged in to leave comments. Login now