Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to search ALL mercurial commits for a specific string?

We have a situation where we know a keyword used in one particular mercurial commit in a repository. But we don't know what commit that is in. Obviously I can go through each committed file and eventually find the keyword and how it was used, but that would be a lot of tedious work.

Is there a way in mercurial to search for a string across ALL committed code in the repository?

like image 286
Angus Comber Avatar asked Mar 21 '14 11:03

Angus Comber


1 Answers

hg grep does exactly that.

hg grep [OPTION]... PATTERN [FILE]...

search for a pattern in specified files and revisions

Search revisions of files for a regular expression.

This command behaves differently than Unix grep. It only accepts
Python/Perl regexps. It searches repository history, not the working
directory. It always prints the revision number in which a match
appears.

By default, grep only prints output for the first revision of a 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
--all flag.

Returns 0 if a match is found, 1 otherwise.
like image 65
Ry4an Brase Avatar answered Oct 20 '22 13:10

Ry4an Brase