diff mercurial/commands.py @ 4877:242026115e6a

hg grep: handle re.compile errors & update tests/test-grep
author Giorgos Keramidas <keramida@ceid.upatras.gr>
date Mon, 09 Jul 2007 17:41:14 +0300
parents 9858477ed74c
children da8640113b5a be5dc5e3ab2d
line wrap: on
line diff
--- a/mercurial/commands.py	Wed Jul 11 19:56:16 2007 -0300
+++ b/mercurial/commands.py	Mon Jul 09 17:41:14 2007 +0300
@@ -1092,7 +1092,11 @@
     reflags = 0
     if opts['ignore_case']:
         reflags |= re.I
-    regexp = re.compile(pattern, reflags)
+    try:
+        regexp = re.compile(pattern, reflags)
+    except Exception, inst:
+        ui.warn(_("grep: invalid match pattern: %s!\n") % inst)
+        return None
     sep, eol = ':', '\n'
     if opts['print0']:
         sep = eol = '\0'