I have not found the need to yet. Though that will probably change when I start doing an automatic commit for each build, since I sometimes do some exploratory coding that I sometimes end up reverting (SCM > Discard Changes).
There does not seem to be support for “merging” or reverting to a revision other than (Subversion’s) BASE in XCode (at least in my 2.5 release), but it should be fairly easy from the command line. To take a single file back to a previous revision, the simplest method to understand goes something like this: [code]# First, make sure target file (TODO) is up to date (otherwise the eventual commit will fail).
$ svn update TODO
Revert the file TODO to the last revision as of 2008-12-10 00:00
$ svn cat -r {2008-12-10} TODO > TODO
OR Revert the file TODO to revision 103
$ svn cat -r 103 TODO > TODO[/code]
The idea is simple: have Subversion extract an old copy and just overwrite the current contents of the file with that old data.
Then review the changes (SCM > Diff With/Compare With, run test suites, etc.) and commit them. It is usually nice to include a note about the reverted file in the commit message (“TODO reverted to 2008-12-10 (r103)”).
If you want to keep most of the changes but undo a few of them, the merge command is helpful. If errors were introduced in revisions 155 and 156 but all the other changes up to HEAD are alright, you can “reverse-merge” only the changes from revision 155 and 156 like this:[code]# Update first.
$ svn update TODO
Merge out the changes made in revisions 155 and 156.
$ svn merge -r 156:154 TODO # note use of 154 (first OK revision), not 155 (first bad revision)[/code]
The newer:older ordering of the revisions makes it do a “reverse-merge” (an undo). Then review and commit the changes. Again, a commit message stating what was reverted is usually handy for later reference.
When the command looks like svn merge -r HEAD:older ., this means remove all the changes committed after older (after older up to and including HEAD). The result is nearly the same as the cat method (overwrite with an old version). The merge method will preserve any uncommitted changes in the file, the cat method will discard them. Also, the merge method might store away extra metadata about what was merged (or ˜unmerged’, as the case may be). Right now, it looks like Subversion only stores this extra merge metadata (svn:mergeinfo property) when merging between branches in the same repository.
Also, the merge command can be used to remove changes from whole subtrees with one command (use a directory name instead of the file name (“TODO” in the above examples)).
PS. I am not sure why the example in the posted link was so verbose. Assuming all the references to “changedFile.txt” are all from the same branch (this seems reasonable given the “roll back” context), then the command could be rendered as svn merge -r HEAD:215 ./folder/changedFile.txt. Does that make it seem less complicated?
PPS. Even if the working copy was supposed to be on a different branch there does not seem to be much need to repeat the whole repository URL: svn merge -r HEAD:215 svn://domain.com/repo/trunk/folder/changedFile.txt ./folder/changedFile.txt.