# HG changeset patch # User Giorgos Keramidas # Date 1183992074 -10800 # Node ID 242026115e6a36fab2aebb7ac059604dd0bd0d28 # Parent 0e2d0a78f81a7a818d48dae8c6e3fdd7bdccf9dc hg grep: handle re.compile errors & update tests/test-grep diff -r 0e2d0a78f81a -r 242026115e6a mercurial/commands.py --- 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' diff -r 0e2d0a78f81a -r 242026115e6a tests/test-grep --- a/tests/test-grep Wed Jul 11 19:56:16 2007 -0300 +++ b/tests/test-grep Mon Jul 09 17:41:14 2007 +0300 @@ -17,6 +17,8 @@ head -n 3 port > port1 mv port1 port hg commit -m 4 -u spam -d '4 0' +echo % pattern error +hg grep '**test**' echo % simple hg grep port port echo % all diff -r 0e2d0a78f81a -r 242026115e6a tests/test-grep.out --- a/tests/test-grep.out Wed Jul 11 19:56:16 2007 -0300 +++ b/tests/test-grep.out Mon Jul 09 17:41:14 2007 +0300 @@ -1,3 +1,5 @@ +% pattern error +grep: invalid match pattern: nothing to repeat! % simple port:4:export port:4:vaportight