tags:

views:

73

answers:

6

Hi,

I am newbie with svn and I stuck after a mistake.

I have two systems:

a) system 1 - working copy with the right code

b) system 2 - working copy with wrong code, committed to the repository by mistake

I would like re-commit the right code from system 1 but I can't. If I change a file and I try to commit it I get the message:

file xyx is out of date

Obviously I can't update the system 1 working copy otherwise I loose the right code.

How can I exit from this deadlock ?

Thank you

Fab.

+5  A: 

Here is an article on how to undo a commit using Subclipse:

How to undo a commit

Basically, you open the history view, select the bad revision and revert it, using the context menu (from the article):

alt text

You can undo the commit from the command line, using svn info / log / merge. Here is a brief article on how to it that way: svn undo from command line

Michael Goldshteyn
Good job! +1. nonetheless this answer depends on subclipse. it describes barely the process using command line.
SDReyes
I added command line info, as well, to make the answer more complete.
Michael Goldshteyn
Sorry, I didn't mentioned it, I am working on mac osx.
Fabrizio
A: 

Copy and paste 1's code into a temporary place.

Update 1.

Replace 1's code with the temporary place.

Commit 1.

Update 2.

Coronatus
A: 

Copy working code from system 1 to system 2, then commit.

Mike Burton
This messed up some svn configuration file and I was not able to connect to the repository any more. Probably I had to copy source files and similar, not all the project file.
Fabrizio
You probably copied the .svn tracking files. Easy way to corrupt your local copy, for sure. Subversion isn't kind to the lazy man, sadly.
Mike Burton
+2  A: 

Use revert. You can revert a file to the revision that you know is good. Then commit that file as a new revision. Be sure you revert to revision rather than update to revision.

JoshD
Maybe I am wrong since my fuzzy understanding of cvs. I have many many files and each of them had a different revision when I committed the wrong code.
Fabrizio
A file will be at the last revision that it was changed. But if you check in a file from revision 4 to revision 10. Grabbing the file as revision 9 will still give you the contents from revision 4. All the files are at the same revision, but they show the last revision in which they were modified. So, if you grab the revision just before your invalid commit, it will get the files in the state they were before that commit.
JoshD
Obviously, I mean svn !!
Fabrizio
JoshD, thank you for clearing me this concept. Very useful.
Fabrizio
+2  A: 

To revert code you mistakenly committed in revision 10:

svn update
svn merge -r10:9 .
svn commit -m'reversing commit made by mistake in -r10'

Now if you want to bring back that code, but keep it uncommitted (perhaps to edit it and then resubmit):

// this assumes that the reversal committed above was -r11.
svn update
svn merge -r11:10 .
Ether
nice solution. console. home, sweet home. +1
SDReyes
A: 

Save a copy of the right code. Update your working system to use the bad code, so now the working system is "current". Add the changes to make the code good (which might just be copying it back in place). Submit the good copy of the code as the next version.

Remember a change is just a change, good or bad. The key is not to lose the good copy of code in the shuffle. There's other ways of doing it, but the basic idea is the same:

  1. Have your code up-to-date (thus grabbing the bad copy).
  2. Modify it to be fight (thus restoring the good copy).
  3. Submit your changes (thus restoring the good copy for everyone).
Edwin Buck