有没有办法搜索特定字符串的所有mercurial提交?

时间:2014-03-21 11:03:56

标签: version-control mercurial

我们知道在存储库中的一个特定mercurial提交中使用的关键字。但是我们不知道提交的是什么。显然我可以浏览每个提交的文件并最终找到关键字及其使用方式,但这将是一项繁琐的工作。

有没有办法在mercurial中搜索存储库中所有已提交代码的字符串?

1 个答案:

答案 0 :(得分:5)

hg grep正是如此。

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.