在mercurial中,我如何找到包含字符串的变更集?

Whi*_*uit 12 mercurial tortoisehg

假设我有以下修订:

rev 1:
+ Dim Foo as integer

rev 2:
+ I like big butts, I cannot lie

rev 3
- Dim Foo as integer
Run Code Online (Sandbox Code Playgroud)

Foo在rev 1和2中,并从三个中移除.我可以发出什么命令将返回添加或删除Foo的所有更改集?

理想情况下,我也希望能够从toroisehg做到这一点

krt*_*tek 20

您可以使用以下grep命令:

hg grep --all Foo
Run Code Online (Sandbox Code Playgroud)

在评论中解决Lazy Badger的问题.

$ hg init
$ echo "Dim Foo as integer" > test 
$ hg commit -m "1"
$ echo "I like big butts, I cannot lie" > test 
$ hg commit -m "2"
$ echo "Dim Foo as integer" > test 
$ hg commit -m "3"
$ hg grep --all Foo
Run Code Online (Sandbox Code Playgroud)

grep命令的输出是:

test:2:+:Dim Foo as integer
test:1:-:Dim Foo as integer
test:0:+:Dim Foo as integer
Run Code Online (Sandbox Code Playgroud)

这意味着,Foo首次出现在修订版0的文件测试中(+符号告诉我们),然后它在版本1(-符号)上消失,并在修订版2上再次出现.

我不知道它是否是您想要的,但它清楚地表明添加或删除搜索词的修订版.