문제

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?

도움이 되었습니까?

해결책

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.
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top