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).
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.
-
7Also known as svn annotate, if you're feeling less vindictive. (Or your boss wrote the code and is looking over your shoulder.) – jmanning2k Jan 15 '10 at 20:59
svn [praise|annotate|blame] filename
gives you the version number and last writer or editor.
svn [praise|annotate|blame] -v filename
will give you additional information. if you have merged the branch, in this case
svn blame -g filename
you should use the following command to know all the available options
svn blame --help
There's the "svn blame" tool for that.
-
3They have an "svn praise" alias for it also, perhaps that will suit you better if you have a bad feeling? ;) – kusma Jan 15 '10 at 21:45
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.
-
Annotate sounds better than blame. At least for what I needed at the time. :-) – Les Jan 19 '10 at 15:33