12

Let's say I have the following revisions:

rev 1:
+ Dim Foo as integer

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

rev 3
- Dim Foo as integer

Foo is in rev 1 & 2, and removed from three. What command can I issue that will return all changesets that Foo was added or deleted?

Ideally I'd like to be able to do this from toroisehg as well

WhiskerBiscuit
  • 4,587
  • 7
  • 51
  • 91
  • possible duplicate of [Finding changesets in mercurial by grepping the patch](http://stackoverflow.com/questions/5330782/finding-changesets-in-mercurial-by-grepping-the-patch) – krtek Mar 15 '12 at 19:18
  • Foo is content of file, filename or text in commit message? – Lazy Badger Mar 15 '12 at 19:32

1 Answers1

21

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.

krtek
  • 25,760
  • 5
  • 54
  • 82