Reversing patches

Last modified: March 1, 2009 - 19:17

You can reverse a patch if you have finished testing it, or if you want to see whether a problem has been introduced by a particular patch. You should also reverse a patch prior to adding a newer, updated version of the same patch. To reverse the patch, use the patch command with the -R option:

patch -p0 -R < path/file.patch

If you've applied more than one patch, or want to revert changes you've made to Drupal core yourself, a useful command is:

cvs -q diff | patch -p0 -R

This creates a diff of all changes to core and reverses it, leaving you with a clean copy of HEAD. If the reverse is successful, you'll see a list of the core files that were reverted. If there's nothing to revert, i.e., you've already got a clean copy of HEAD, you might instead see a message similar to 'only garbage was found in the patch'.

Another way of reverting to a clean copy of core is by using:

cvs -q update -C
// or even...
cvs -q update -Cd

... but CVS will automatically backup the changed files as .#>old-name<. To remove those, use:

find . -name ".#*" | xargs rm

Trying to revert to clean copy of core

mziegmann - April 28, 2009 - 14:12

When I use any of the commands above to revert to a clean copy of core, I get this message:

cvs update: No CVSROOT specified! Please use the `-d' option
cvs [update aborted]: or set the CVSROOT environment variable.

I am doing this from the root folder. Should I be somewhere else?

Can someone help?

 
 

Drupal is a registered trademark of Dries Buytaert.