You just committed a change to the repository and now you realize it was a mistake; how do you back your changes out in the working copy and recommit the corrected version?
Easy; use the merge subcommand which can create and apply a diff between two revisions.
Say the oops code lies in version 198 and you want to back your changes out to version 197, then use merge like so:
svn merge -r198:197 myfile.pl
Notice how the is from 198 to 197, so the changes will be backed out.
Now commit the corrected version back in to the repository:
svn ci -m ‘Backed out that nasty divide by zero…’
This works great. Thanks!
Whatever you do, don’t specify multiple file names on the command line. If you accidentally committed two files, and you want to use ‘svn merge’ to get them both back to, say, revision 198, you *must* issue two ‘svn merge’ commands, one for each file. If you specify both files on the same command line, svn will merge the two files with eachother. Bad stuff!
Thanks again!
Instead of using version numbers, you can also use HEAD and PREV:
svn merge -rHEAD:PREV myfile.pl