如何找到所有修改了函数引用的变更集?

4

我需要找到与Save()方法相关的所有最近更改的代码。我需要一个Mercurial命令来查找添加或修改引用字符串“Save();”的行的每个变更集/文件。

我不仅需要更改集,还需要查看更改发生的文件。

2个回答

5
似乎你正在寻找类似于的东西。
hg grep --all 'Save();'

那应该以格式显示每个文件的更改。
<file path>:<revision>:+ or -:<line of code changed>

--all标志非常有用,可以确保您获取所有引用。默认情况下,hg在找到第一个引用后(通过向后搜索修订列表)停止查看文件。另请注意,您几乎肯定需要限制您搜索的修订范围,因为在大型repo上执行此操作需要相当长的时间。

如果您使用的是Unix系统,则应该能够将grep命令的输出导入文件中(它运行时间较长,您可能希望缓存它以防第一次没有正确获取后面的内容)。

cat saved_grep_results | awk 'BEGIN {FS=":"} {print $1" "$2}' | uniq

那应该会给你所需查看的文件和版本列表。

1
你正在寻找 hg grep。它接受 Perl/Python 正则表达式,并返回在第一个匹配的文件修订版中找到的结果。
hg grep [OPTION]... PATTERN [FILE]...

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.

所以在你的情况下,类似这样的内容

hg grep Save

至少应该是一个很好的起点。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接