How to undo an Update on SVN
I'm using SVN with Xcode. After implementing a certain functionality in my working copy, I was ready to commit my code to the repository. However the server copy开发者_JAVA技巧 had been modified since my last checkout. So I thought the best thing to do would be to update my project first, resolve conflicts if any, and then finally commit the code. I did just that. But now I find that there are a bunch of errors in my Project. These errors are mostly in the section of code that my co-worker had been working on. So I'm hesitant to modify his code to resolve the errors. Is there a way I can undo the update ? As my code was working perfectly fine before the update, I'd like to continue working on it and maybe merge and commit my changes at a later stage. Is there way I can do this?
XCode allows you to update code to a specific revision. I'm not sure how to do this in XCode 4, but in XCode 3.2 you right click on a class file and click "Get Info". In the info window, go to the "SCM" tab. Over there you'll see a list of all the SVN revisions for that class file. You should see your coworker's revision there, accompanied by his check in comment. Select the revision JUST BEFORE that one (this is the one you were working on before you did an update). XCode will now allow you to update to that revision (Via an update button at the bottom of the info window).
Do these steps for all class files affected by the erroneous update and you should be good to go!
Also, you should probably inform your coworker to not check in erroneous code as a best practice :)
This is what you should be looking at:
EDIT:
For XCode4, I did some research and if what I found out so far is true, I'm SEVERELY disappointed with SCM functionality in XCode4 (refer: Where is the 'Revert' option in Xcode 4's Source Control?)
So I have determined that the functionality to update to a specific revision has been pulled out of Xcode4 (If I am wrong I stand open to correction).
There is, however, a workaround (though this results in the files you're working in get the "M" flag for modified next to them, rather than the "U" flag which means you're working on a previous revision).
In XCode4, on the toolbar at the top, select View>>Editor>>Version.
In this editor, XCode4 shows your class files in two editor windows, one with your local revision and one with the latest from the repository.
At the bottom of each editor window is a toolbar that lists the specific revision you're looking at.
This toolbar is clickable and lets you switch the view to another revision.
Once you do that, I'm afraid you'll simply have to copy-paste that code into your local class file.
This method will ensure that you're working with a working copy of the code. However, it may not be the right way to do it (though at the moment, it's the ONLY way).
Two other solutions I have are:
1 (not recommended)
Work with a copy of XCode 3.2 somehow
2 (depends on the level of functionality you're looking for)
Download a licensed copy of SmartSVN which let's you update files to specific revisions.
You need to do the reverse merge from his revision. Check out this thread: http://www.svnforum.org/threads/31710-how-to-undo-merge-after-svn-update
Slight offtopic: tired of having similar problems, my team decided to switch to the Mercurial and haven't regretted that even once.
精彩评论