Most of the previous answers have been using a reverse merge, and that's usually the right answer. However, there's one situation (which just happened to me) where it's not.
I accidentally changed a file with Unix line endings to DOS line endings when making a small change, and committed it. This is easily undone, either by changing the line endings and committing again, or by a reverse merge, but it has the effect of making svn blame
list my edit as the source of every line of the file. (Interestingly, TortoiseSVN on Windows doesn't get affected by this; only the command line svn blame
.)
If you want to maintain the history as reported by svn blame
, I think you need to do the following:
- Delete the file and commit.
- In the repository, copy the previous good copy of the file into the head, and commit.
- Restore any edits that you do want to keep.
The deletion is a little scary, but remember you always have the file saved in the repository, so restoring it is not a big deal. Here's some code to illustrate the steps. Assume that xxx
is the revision number of the last good copy.
svn rm svn+ssh://path/to/file
svn copy svn+ssh://path/to/file@xxx svn+ssh://path/to -m"Restore good copy"
svn update
<restore the edits>
svn commit -m"Restore edits"
Note that for a copy in the repository, the destination needs to be a directory, not a filename.