diff -r e1987261dd05 -r 9ef10437bb88 mercurial/commands.py --- a/mercurial/commands.py Tue Jul 10 13:18:34 2018 +0200 +++ b/mercurial/commands.py Fri Jul 06 00:39:21 2018 +0530 @@ -2515,11 +2515,12 @@ Search revision history for a regular expression in the specified files or the entire project. - By default, grep prints the most recent revision number for each - file in which it finds a match. To get it to print every revision - that contains a change in match status ("-" for a match that becomes - a non-match, or "+" for a non-match that becomes a match), use the - --diff flag. + By default, grep searches the expression on the working directory. + To search history and show the most recent revision number for each + file in which it finds a match, use :hg:`grep -r tip:0`. + To get it to print every revision that contains a change in match status + ("-" for a match that becomes a non-match, or "+" for a non-match that + becomes a match), use the --diff flag. PATTERN can be any Python (roughly Perl-compatible) regular expression. @@ -2544,6 +2545,10 @@ if opts.get('print0'): sep = eol = '\0' + if not opts.get('rev') and not diff: + opts['rev'] = ["wdir()"] + opts['allfiles'] = True + getfile = util.lrucachefunc(repo.file) def matchlines(body):