
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
64
|
Chapter 4: Branching and Merging
Undoing Changes
Another common use for svn merge is to roll back a change that has already been
committed. Suppose you’re working away happily on a working copy of /calc/trunk,
and you discover that the change made way back in revision 303, which changed
integer.c, is completely wrong. It never should have been committed. You can use
svn
merge
to undo the change in your working copy, and then commit the local modifica-
tion to the repository. All you need to do is to specify a reverse difference:
$ svn merge -r 303:302 http://svn.example.com/repos/calc/trunk
U integer.c
$ svn status
M integer.c
$ svn diff
...
# verify that the change is removed
...
$ svn commit -m "Undoing change committed in r303."
Sending integer.c
Transmitting file data .
Committed revision 350.
One way to think about a repository revision is as a specific group of changes (some
version control systems call these changesets). By using the
-r switch, you can ask svn
merge
to apply a changeset, or whole range of changesets, to your working copy. In
our case of undoing a change, we’re asking
svn merge to apply changeset 303 to our
working copy backwards.
Keep in mind that rolling back a change like this is just like any other
svn merge
operation, so you should use svn status and svn diff to confirm ...