mercurial/fileset.py
branchstable
changeset 17368 01cc267fc105
parent 17367 ce625185cfd9
child 17371 1310489eb5d6
equal deleted inserted replaced
17367:ce625185cfd9 17368:01cc267fc105
   254 
   254 
   255 def grep(mctx, x):
   255 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,
   264               M=2**20, MB=2**20, G=2**30, GB=2**30)
   267               M=2**20, MB=2**20, G=2**30, GB=2**30)
   265 
   268