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?
6 Answers
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

- 349,597
- 67
- 533
- 578
-
16`svn cat -r 666 file | less` is perfect so I can read through it with vim! – Xeoncross Nov 18 '10 at 20:06
-
5@sillyMunky Try `svn cat | vim -`. If vim's syntax highlighting doesn't automatically kick in, do `:set syntax=java` (or whichever language). – John Kugelman Nov 27 '12 at 04:10
-
1Thanks very much John, actually I'm on debian and I found there's a nice little syntax highlighting package called 'source-highlight' so less can automagically pickup syntax highlighting (actually I now alias this to lesss for distinction). – sillyMunky Nov 27 '12 at 16:34
-
3svn cat -r 666 file > file_666.js if you would like to view that entire file :p – Parijat Kalia Sep 24 '13 at 16:22
-
or if you are using bash `vim +set\ ft=
<( svn cat -r – h4unt3r Aug 02 '14 at 22:27)`
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

- 2,661
- 5
- 31
- 39
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.

- 12,239
- 17
- 54
- 73
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...
)

- 221
- 5
- 16
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.

- 30,738
- 21
- 105
- 131

- 11
- 1