svn: How do I determine the last time a certain line was changed?

Viewed 24725

I have a bit of code that I would like to see revision history for. In the example file, line 300 contains something "interesting". How can I use svn to see when that line has been changed and review the svn comment(s) that pertain to the changing of that line. (Note that previous revisions of that file will likely not have my target line of interest at line 300).

6 Answers

You could use SVN's blame command. This will print author and revision numbers on a per-line basis for the specified target. Once you have the revision number you can review the commit logs and other changes associated with that revision using log, etc.

There's the "svn blame" tool for that.

svn blame filename

Then look at the log for the revision in which it was changed.

As others have already mentioned, you can use:

svn annotate filename

to show when that line was last modified. Do be careful though, since that will show the last time that anything on that line was modified. So, if the code was moved in the file, that is deleted from one place, and pasted somewhere else, it will show when the line was moved, not necessarily when it was modified. The same goes if the line was moved into, or out of, a loop, or if statement.

Related