<p>Is it possible to see the history of changes to a particular line of code in a Subversion repository?</p>

<p>I'd like, for instance, to be able to see when a particular statement was added or when that statement was changed, even if its line number is not the same any more.</p>

[{'answer_id': 53633, 'author': 'Maximilian', 'author_id': 1733, 'author_profile': 'https://Stackoverflow.com/users/1733', 'pm_score': 0, 'selected': False, 'text': '<p>svn blame shows you which checkin modified any line in a file the last time.</p>\n\n<p>This works on old revisions too.</p>\n'}, {'answer_id': 53634, 'author': 'Brad Wilson', 'author_id': 1554, 'author_profile': 'https://Stackoverflow.com/users/1554', 'pm_score': -1, 'selected': False, 'text': '<p>The command you\'re looking for is <a href="http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.blame.html" rel="nofollow noreferrer"><code>svn blame</code></a>.</p>\n'}, {'answer_id': 53636, 'author': 'Peter Hoffmann', 'author_id': 720, 'author_profile': 'https://Stackoverflow.com/users/720', 'pm_score': 0, 'selected': False, 'text': '<p>A start is the command svn blame (or annotate,praise). It will show you when a line of code was last modified and by whom it was modified. e.g.:</p>\n\n<pre><code>  4564    wiemann # $Id$\n  4564    wiemann # Author: David Goodger &lt;goodger@python.org&gt;\n   778    goodger # Copyright: This module has been placed in the public domain.\n   217    goodger \n</code></pre>\n'}, {'answer_id': 53640, 'author': 'Marcio Aguiar', 'author_id': 4213, 'author_profile': 'https://Stackoverflow.com/users/4213', 'pm_score': 1, 'selected': False, 'text': '<pre><code>svn annotate\n</code></pre>\n\n<p>The AKA <em>SVN Blame</em> from <a href="http://en.wikipedia.org/wiki/TortoiseSVN" rel="nofollow noreferrer">TortoiseSVN</a>.</p>\n'}, {'answer_id': 53644, 'author': 'morechilli', 'author_id': 5427, 'author_profile': 'https://Stackoverflow.com/users/5427', 'pm_score': 7, 'selected': True, 'text': '<p>I don\'t know a method for tracking statements through time in Subversion.</p>\n\n<p>It is simple however to see when any particular line in a file was last changed using <code>svn blame</code>. Check the SVNBook: <a href="http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.blame.html" rel="noreferrer"><code>svn blame</code> reference</a>:</p>\n\n<p><strong>Synopsis</strong></p>\n\n<pre><code>svn blame TARGET[@REV]...\n</code></pre>\n\n<p><strong>Description</strong></p>\n\n<p>Show author and revision information in-line for the specified files or URLs. Each line of text is annotated at the beginning with the author (username) and the revision number for the last change to that line.</p>\n'}, {'answer_id': 197895, 'author': 'Rafał Dowgird', 'author_id': 12166, 'author_profile': 'https://Stackoverflow.com/users/12166', 'pm_score': 6, 'selected': False, 'text': '<p>In the <a href="http://tortoisesvn.tigris.org/" rel="noreferrer">TortoiseSVN</a> client there is a very nice feature that lets you:</p>\n\n<ul>\n<li>blame a file, displaying the last change for each line (this is standard)</li>\n<li>"blame previous revision", after clicking on a particular line in the above view (this is the good one)</li>\n</ul>\n\n<p>The second feature does what it says - it shows the annotated revision preceding the last modification to the line. By using this feature iteratively, you can trace back through the history of a particular line.</p>\n'}, {'answer_id': 9137338, 'author': 'atedja', 'author_id': 1015188, 'author_profile': 'https://Stackoverflow.com/users/1015188', 'pm_score': 4, 'selected': False, 'text': "<p>I'd usually:</p>\n\n<ol>\n<li>Run <code>svn blame FILE</code> first.</li>\n<li>Note the last revision of the particular line.</li>\n<li><p>Do another query with the <code>-r</code> argument:</p>\n\n<pre><code>svn blame FILE -r 1:REV\n</code></pre></li>\n<li>Trace manually from there.</li>\n</ol>\n"}, {'answer_id': 27187583, 'author': 'Serge Kutny', 'author_id': 1766641, 'author_profile': 'https://Stackoverflow.com/users/1766641', 'pm_score': 3, 'selected': False, 'text': '<p>This can be done in two stages:</p>\n\n<ol>\n<li><code>svn blame /path/to/your/file &gt; blame.tmp</code></li>\n<li><code>grep "your_line_of_text" blame.tmp</code></li>\n</ol>\n\n<p>You can delete blame.tmp file afterwards if you don\'t need it.</p>\n\n<p>In principle, a simple script can be written in any scripting language that does roughly the same.</p>\n'}, {'answer_id': 32481771, 'author': 'Youssef NAIT', 'author_id': 4782694, 'author_profile': 'https://Stackoverflow.com/users/4782694', 'pm_score': 2, 'selected': False, 'text': '<p>In <a href="http://en.wikipedia.org/wiki/Eclipse_%28software%29" rel="nofollow noreferrer">Eclipse</a> you can know when each line of your code has been committed using the SVN annotate view, or right click on the file → <em>Team</em> → <em>Show annotation...</em>. </p>\n'}, {'answer_id': 37281937, 'author': 'tniles', 'author_id': 1228878, 'author_profile': 'https://Stackoverflow.com/users/1228878', 'pm_score': 2, 'selected': False, 'text': '<p>The key here is how much history is required. As others have pointed out, the short answer is: <code>svn blame</code> (see <code>svn help blame</code> for details). If you\'re reaching far back in history or dealing with significant changes, you will likely need more than just this one command.</p>\n\n<p>I just had to do this myself, and found this (ye ole) thread here on SO. Here\'s what I did to solve it with just the <code>CLI</code>, specifically for my case where an API had changed (e.g. while porting someone\'s far outdated work (not on a branch, <em>arrgh!</em>) back into a feature branch based off of an up-to-date trunk). E.g. function names had changed enough to where it wasn\'t apparent which function needed to be called.</p>\n\n<h1>Step One</h1>\n\n<p>The following command allowed me to page through commits where things had changed in the file "fileName.h" and to see the corresponding revision number (note: you may have to alter the \'10\' for more or less context per your svn log text).</p>\n\n<p><code>svn log | grep -C 10 "fileName.h" | less</code> </p>\n\n<p><em>This results in a list of revisions in which this file was modified.</em></p>\n\n<h1>Step Two</h1>\n\n<p>Then it was a simple matter of using <code>blame</code> (or as others have pointed out, <code>annotate</code>) to narrow down to the revisions of interest.</p>\n\n<pre><code>cd trunk\nsvn blame fileName.h@r35948 | less\n</code></pre>\n\n<p><em>E.g. found the revision of interest was 35948.</em></p>\n\n<h1>Step Three</h1>\n\n<p>Having found the revision(s) of interest via blame, a diff can be produced to leverage the SVN tool. </p>\n\n<pre><code>svn diff -r35948:PREV fileName.h\n</code></pre>\n\n<h1>Conclusion</h1>\n\n<p>Having a visual diff made it much easier to identify the old API names with the newer/updated API names.</p>\n'}, {'answer_id': 57630362, 'author': 'Harrison Mc', 'author_id': 7343786, 'author_profile': 'https://Stackoverflow.com/users/7343786', 'pm_score': 0, 'selected': False, 'text': "<p>If you use Emacs, the built-in package <code>vc</code> can do this. </p>\n\n<ol>\n<li>Navigate to the file in question.</li>\n<li>Run the command <code>vc-annotate</code> with either <kbd>M-x</kbd> <code>vc-annotate</code> or <kbd>C-x</kbd><kbd>v</kbd><kbd>g</kbd>.</li>\n<li>Each line will show up with its revision, like a normal <code>svn blame</code>.</li>\n<li>Pressing <kbd>a</kbd> (<code>vc-annotate-revision-previous-to-line</code>) will navigate to the revision before the revision at the line you're on.</li>\n</ol>\n"}]
['https://Stackoverflow.com/questions/53629', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1428/']