In mercurial how can I find changesets that contain a string?

左心房为你撑大大i 提交于 2019-12-03 11:20:26

You can use the grep command :

hg grep --all Foo

To address Lazy Badger concerns in comments.

$ 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

The output of the grep command is :

test:2:+:Dim Foo as integer
test:1:-:Dim Foo as integer
test:0:+:Dim Foo as integer

Which means, Foo was first seen in the file test on revision 0 (the + sign tells us that), then it dissapeared on revision 1 (the - signs), and reappear again on revision 2.

I don't know if it is what you want, but it clearly indicates revision on which the searched word was added or deleted.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!