tags:

views:

3375

answers:

5

I'm working on a project with a friend and i wanna return to an older version of our code and set it to be the current how do i do it?

I'm using anksvn on vs08

i have the version tat i want on my pc but the commit is failing, the message that i get is "commit is failed, file or directory is out of date"

i also have subversion client on my pc

A: 

Sync to the older version and commit it. This should do the trick.

Here's also an explanation of undoing changes.

Mork0075
+8  A: 

Basically you need to "merge backwards" - apply a diff between the current and previous version to the current version (so you end up with a working copy looking like the old version) and then commit again. So for example to go from revision 150 (current) back to revision 140:

svn update
svn merge -r 150:140 .
svn commit -m "Rolled back to r140"

The Subversion Red Book has a good section about this.

Jon Skeet
but the merge is not override my changes and the new revision.
Chen Kinnrot
Which changes? Any changes you don't want in your working copy can just be removed with svn revert. Committed changes will be 'undone' by this merge.
Jon Skeet
A: 

Right-click on the highest hierarchy you want to revert >> Revert or Revert to Revision

Yuval A
+1  A: 

The reason you can't do anything directly with the good copy you have on your PC, is that its .svn folders know that it is code from the past, so requires an update. But you can only actually commit changes at the head of the subversion history.

You can use

svn update -r <earlier_revision_number>

to check various older versions of your project, until you find the right revision number, of your good version. When you have found it, update to the newest (head) revision, then apply the svn merge as suggested above.

If you really can't find it, and need to commit the copy on your PC, then get a fresh update to the latest version, and copy your "good" version over the top of it (without the .svn folders!). Delete any files that weren't in the good copy from the folders and from subversion, and commit what you have now.

joeytwiddle
+1  A: 

The standard way of using merge to undo the entire check-in works great, if that's what you want to do. Sometimes, though, all you want to do is revert a single file. There's no legitimate way to do that, but there is a hack:

  1. Find the version that you want using svn log.
  2. Use svn's export subcommand:

    svn export http://url-to-your-file@123 /tmp/filename

(Where 123 is the revision number for a good version of the file.) Then either move or copy that single file to overwrite the old one. Check in the modified file and you are done.

Bill