Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I view all historical changes to a file in SVN

Tags:

svn

I know that I can svn diff -r a:b repo to view the changes between the two specified revisions. What I'd like is a diff for every revision that changed the file. Is such a command available?

like image 954
Gordon Wilson Avatar asked Nov 12 '08 02:11

Gordon Wilson


People also ask

Where is svn history stored?

They are stored in the svn:log property. You can add the --revprop flag to the various property commands to view & edit this property.

How do I find old revision in svn?

By far the easiest way to revert the changes from one or more revisions, is to use the revision log dialog. Select the file or folder in which you need to revert the changes. If you want to revert all changes, this should be the top level folder. Select TortoiseSVN → Show Log to display a list of revisions.

How do I find svn modified files?

To get an overview of your changes, use the svn status command. You may use svn status more than any other Subversion command. If you run svn status at the top of your working copy with no arguments, it detects all file and tree changes you've made.

Which is the svn command to see the list of changes made in a working copy before committing to the repository?

The svn log command is used to display all the commits made on the repository or file. The svn log command is executed as follows: svn log Path.


2 Answers

There's no built-in command for it, so I usually just do something like this:

#!/bin/bash  # history_of_file # # Outputs the full history of a given file as a sequence of # logentry/diff pairs.  The first revision of the file is emitted as # full text since there's not previous version to compare it to.  function history_of_file() {     url=$1 # current url of file     svn log -q $url | grep -E -e "^r[[:digit:]]+" -o | cut -c2- | sort -n | {  #       first revision as full text         echo         read r         svn log -r$r $url@HEAD         svn cat -r$r $url@HEAD         echo  #       remaining revisions as differences to previous revision         while read r         do             echo             svn log -r$r $url@HEAD             svn diff -c$r $url@HEAD             echo         done     } } 

Then, you can call it with:

history_of_file $1 
like image 194
bendin Avatar answered Oct 12 '22 00:10

bendin


Slightly different from what you described, but I think this might be what you actually need:

svn blame filename 

It will print the file with each line prefixed by the time and author of the commit that last changed it.

like image 45
ngn Avatar answered Oct 11 '22 23:10

ngn