How do I view an older version of an SVN file?

SvnRollbackRevision

Svn Problem Overview


I have an SVN file which is now missing some logic and so I need to go back about 40 revisions to the time when it had the logic I need. Other than trying to view a diff of the file in the command line (very hard to read), is there any way I could get a copy of that file to review so I can study it to recover parts?

Svn Solutions


Solution 1 - Svn

You can update to an older revision:

svn update -r 666 file

Or you can just view the file directly:

svn cat -r 666 file | less

Solution 2 - Svn

It is also interesting to compare the file of the current working revision with the same file of another revision.

You can do as follows:

$ svn diff -r34 file

Solution 3 - Svn

Update to a specific revision:

svn up -r1234 file

Solution 4 - Svn

I believe the best way to view revisions is to use a program/app that makes it easy for you. I like to use trac : http://trac.edgewall.org/wiki/TracSubversion

It provides a great svn browser and makes it really easy to go back through your revisions.

It may be a little overkill to set this up for one specific revision you want to check, but it could be useful if you're going to do this a lot in the future.

Solution 5 - Svn

To directly answer the question of how to "get a copy of that file":

svn cat -r 666 file > file_r666

then you can view the newly created file_r666 with any viewer or comparison program, e.g.

kompare file_r666 file

nicely shows the differences.

I posted the answer because the accepted answer's commands do actually not give a copy of the file and because svn cat -r 666 file | vim does not work with my system (Vim: Error reading input, exiting...)

Solution 6 - Svn

Using the latest versions of Subclipse, you can actually view them without using the cmd prompt. On the file, simply right-click => Team => Switch to another branch/tag/revision. Besides the revision field, you click select, and you'll see all the versions of that file.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionXeoncrossView Question on Stackoverflow
Solution 1 - SvnJohn KugelmanView Answer on Stackoverflow
Solution 2 - SvnKreshnikView Answer on Stackoverflow
Solution 3 - SvnchrisView Answer on Stackoverflow
Solution 4 - SvnwajiwView Answer on Stackoverflow
Solution 5 - SvnrehctawratsView Answer on Stackoverflow
Solution 6 - SvnKheemView Answer on Stackoverflow