Alex Rivera | Logout

How to switch back to a previous version of a file without deleting its subsequent revisions?

Asked 2008-09-18T16:35:11.127
11

I have 4 versions of file A.txt in my subversion repository, say: A.txt.r1, A.txt.r2, A.txt.r3 and A.txt.r4. My working copy of the file is r4 and I want to switch back to r2. I don't want to use "svn update -r 2 A.txt" because this will delete all the revisions after r2, namely r3 and r4.

So is there any way that I update my working copy to r2 and still having the option to switch to r3 and r4 later? Put it another way, I want to still be able to see all 4 revisions by using "svn log A.txt" after doing the update.

svn
Edit
Report

4 Answers

3

I don't have a lot of experience with Subversion so please excuse me if this method doesn't work in this environment.

In this situation I follow these steps:

  1. Check out the file in question ready for editing as r4
  2. Overwrite your local copy of the file with the revision you require, in this case r2
  3. Check in / commit this "new" revision of the file as r5 with an appropriate comment

This way when you go through your file history you will see something like:

  • r1
  • r2
  • r3
  • r4
  • r5 (comment: "reverted to r2 content")
answered 2008-09-18T16:45:33.130
3
svn update -r 2 A.txt

This command will not delete any versions in the repository. It will set your working copy of A.txt to be revision 2. You can see this by doing

> svn status -u A.txt
  *     2   A.txt

The output of this command show that you are viewing version 2, and that there are updates (that's the *).

After doing this update, you will still be able to do "svn log" and see all the revisions.

Performing "svn update A.txt" will return you to the latest version (in your case, r4).

answered 2008-09-18T16:56:26.473
2

"I don't want to use "svn update -r 2 A.txt" because this will delete all the revisions after r2, namely r3 and r4."

Uh... it won't, actually. Try it: do a regular svn update after the -r 2 one and you'll see the working copy updated back to r4.

answered 2008-09-18T16:40:59.287
1

Update won't delete any revisions on the server. The only changes it makes are to your local working copy:

SVN Update Command

"brings changes from the repository into your working copy"

"synchronizes the working copy to the revision given by the --revision switch"

answered 2008-09-18T16:41:23.233

Your Answer