0

So there is a bug in a bit of code I wrote a long while back. When I went to look into it, it had all been changed! I don't know which colleague changed it. I don't know when it was changed. This file has been changed many, many times. I'm not concerned with everytime this file has a commit. I definitely don't want too look through all 100 commits this file has been in just to find which commits changed this area of code.

I want to find all of the commits that affected file xyz.txt between lines 250 and 300.

Better yet, I want to find all of the commits that affected the function doStuff() in file xyz.txt.

Is that possible?

Shane
  • 827
  • 8
  • 18
  • Try `git bisect`. – Lasse V. Karlsen Mar 07 '17 at 22:35
  • I accidentally added the git tag. I'm using mercurial. If it isn't possible in mercurial, I'll switch VCS. – Shane Mar 07 '17 at 22:39
  • 2
    Mercurial and Git are pretty equal in capabilities, and sometimes even use the same command names. In this case, the commands are `hg blame` and `hg bisect` which correspond to `git blame` and `git bisect` (though the usages are a little bit different). – torek Mar 07 '17 at 23:45

1 Answers1

0

As torek said, hg blame will do the job. To filter lines between 250 and 300 you could do:

hg blame -ucd xyz.txt | cat -n | sed -n 250,300p

-u: Show user

-c: Show changeset

-d: Show date

Diego Ocampo
  • 143
  • 8