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

发布于 2024-11-01 15:11:41 字数 126 浏览 1 评论 0原文

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

我需要的不仅仅是更改集,我还需要查看进行更改的文件。

I need to find all recent changes to our code that are related to the Save() method. I need a mercurial command to find every changeset/files in which a line that refers to the string "Save();" was added or modified.

I need more that just the changesets, I need to review the files where the changes where made.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

北笙凉宸 2024-11-08 15:11:41

看起来你正在寻找类似的东西

hg grep --all 'Save();'

这应该给你格式中的每个文件更改

<file path>:<revision>:+ or -:<line of code changed>

--all 标志对于确保你获得所有引用很有用,因为默认情况下 hg 在找到文件后停止查看文件第一个参考(通过修订列表向后搜索)。另请注意,您几乎肯定会想要限制搜索的修订范围,因为这在较大的存储库上需要相当多的时间。

如果您使用的是 unix 系统,您应该能够将 grep 命令的输出通过管道传输到文件中(运行需要一段时间,您可能需要缓存它,以防您一开始没有得到后面的内容)时间)

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

这应该会为您提供您想要查看的文件和修订版本的列表。

It seems like you're looking for something like

hg grep --all 'Save();'

That should give you every file change in the format

<file path>:<revision>:+ or -:<line of code changed>

The --all flag is useful to make sure that you get all of the references, as by default hg stops looking at a file after it finds the first reference (searching backwards through the revision list). Also note that you'll almost certainly want to limit the revision range you search on, as this takes quite a bit of time on a largish repo.

If you're on a unix system, you should be able to pipe the output of the grep command into a file (it takes awhile to run, you probably want to cache it in case you don't get the later stuff right the first time)

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

That should give you the list of files and revisions that you want to look at.

依 靠 2024-11-08 15:11:41

您正在寻找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

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

You are looking for hg grep. It takes a Perl/Python regex and returns a result for the first revision of a file in which it finds a match.

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.

So in your case, something like

hg grep Save

should at least be a good starting place.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文