
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
66
|
Chapter 4: Branching and Merging
That was the hard part—the research. Now that you know what you want to restore,
you have two different choices.
One option is to use
svn merge to apply revision 808 in reverse. (We’ve already dis-
cussed how to undo changes; see “Undoing Changes” earlier in this chapter.) This
would have the effect of re-adding real.c as a local modification. The file would be
scheduled for addition, and after a commit, the file would again exist in
HEAD.
In this particular example, however, this is probably not the best strategy. Reverse-
applying revision 808 would not only schedule real.c for addition, but the log mes-
sage indicates that it would also undo certain changes to integer.c, which you don’t
want. Certainly, you could reverse-merge revision 808 and then
svn revert the local
modifications to integer.c, but this technique doesn’t scale well. What if there were
90 files changed in revision 808?
A second, more targeted strategy is not to use
svn merge at all, but rather the svn
copy
command. Simply copy the exact revision and path coordinate pair from the
repository to your working copy:
$ svn copy --revision 807 \
http://svn.example.com/repos/calc/trunk/real.c ./real.c
$ svn status
A + real.c
$ svn commit -m "Resurrected real.c from revision 807, /calc/trunk/real.c." ...