mercurial/commands.py
changeset 38631 9ef10437bb88
parent 38598 afef1e362d65
child 38648 ffd08ec22955
equal deleted inserted replaced
38630:e1987261dd05 38631:9ef10437bb88
  2513     """search revision history for a pattern in specified files
  2513     """search revision history for a pattern in specified files
  2514 
  2514 
  2515     Search revision history for a regular expression in the specified
  2515     Search revision history for a regular expression in the specified
  2516     files or the entire project.
  2516     files or the entire project.
  2517 
  2517 
  2518     By default, grep prints the most recent revision number for each
  2518     By default, grep searches the expression on the working directory.
  2519     file in which it finds a match. To get it to print every revision
  2519     To search history and show the most recent revision number for each
  2520     that contains a change in match status ("-" for a match that becomes
  2520     file in which it finds a match, use :hg:`grep -r tip:0`.
  2521     a non-match, or "+" for a non-match that becomes a match), use the
  2521     To get it to print every revision that contains a change in match status
  2522     --diff flag.
  2522     ("-" for a match that becomes a non-match, or "+" for a non-match that
       
  2523     becomes a match), use the --diff flag.
  2523 
  2524 
  2524     PATTERN can be any Python (roughly Perl-compatible) regular
  2525     PATTERN can be any Python (roughly Perl-compatible) regular
  2525     expression.
  2526     expression.
  2526 
  2527 
  2527     If no FILEs are specified (and -f/--follow isn't set), all files in
  2528     If no FILEs are specified (and -f/--follow isn't set), all files in
  2541         ui.warn(_("grep: invalid match pattern: %s\n") % pycompat.bytestr(inst))
  2542         ui.warn(_("grep: invalid match pattern: %s\n") % pycompat.bytestr(inst))
  2542         return 1
  2543         return 1
  2543     sep, eol = ':', '\n'
  2544     sep, eol = ':', '\n'
  2544     if opts.get('print0'):
  2545     if opts.get('print0'):
  2545         sep = eol = '\0'
  2546         sep = eol = '\0'
       
  2547 
       
  2548     if not opts.get('rev') and not diff:
       
  2549         opts['rev'] = ["wdir()"]
       
  2550         opts['allfiles'] = True
  2546 
  2551 
  2547     getfile = util.lrucachefunc(repo.file)
  2552     getfile = util.lrucachefunc(repo.file)
  2548 
  2553 
  2549     def matchlines(body):
  2554     def matchlines(body):
  2550         begin = 0
  2555         begin = 0