gibuu is hosted by Hepforge, IPPP Durham
GiBUU
close Warning:
• Error with navigation contributor "BrowserModule"
• Failed to sync with repository "(default)": instance.__dict__ not accessible in restricted mode; repository information may be out of date. Look in the Trac log for more information including mitigation strategies.

# Handling Patches

Patches are a useful concept for handling local code modifications. They can be handy e.g. for transferring (uncommitted) changes from one branch to another (or from one computer to another).

## 1) Producing a patch

A patch is a file which contains code modifications in "diff" format. You can easily write all local modifications in an svn working copy to a file by doing:

svn diff > patch.diff


This will produce a file called 'patch.diff' which contains all the changes. If you only want the changes from specific files or directories, you can do:

svn diff someDir/ someFile.f90 > patch.diff


If you want to produce a patch of a certain revision (let's say rev. 1234) in an svn repository, you can do:

svn diff -c1234 > patch.diff


This will include all changes made in that particular revision. If you want a patch of all modifications in a given range of revisions, do:

svn diff -r1234:5678 > patch.diff


This will include the modifications of all revisions after 1234 up to (and including) 5678. The changes of revision 1234 will not be included.

## 2) Applying a patch

Once you have a patch file, you can apply it e.g. to another svn branch (or even to a directory which is not under version control) via:

patch -p0 < patch.diff


This will apply the changes from the patch file to the current directory. To apply the patch reversely (i.e. undo the changes), use:

patch -p0 -R < patch.diff


## 3) Reverting a revision

A committed revision can be reverted by producing a diff of that revision and applying it reversely ("-R"):

svn diff -c1234 > patch.diff
patch -p0 -R < patch.diff


This can then be committed, in order to revert the changes in the repository. To revert local changes in your working copy, you can use:

svn revert