| 1 | = Handling Patches = |
| 2 | |
| 3 | Patches are a useful concept for handling local code modifications. They can be handy e.g. for transferring changes from one branch to another (or from one computer to another). |
| 4 | |
| 5 | == 1) Producing a patch == |
| 6 | |
| 7 | 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: |
| 8 | |
| 9 | {{{ |
| 10 | svn diff > patch.diff |
| 11 | }}} |
| 12 | |
| 13 | 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: |
| 14 | |
| 15 | {{{ |
| 16 | svn diff someDir/ someFile.f90 > patch.diff |
| 17 | }}} |
| 18 | |
| 19 | If you want to produce a patch of a certain revision (let's say rev. 1234) in an svn repository, you can do: |
| 20 | |
| 21 | {{{ |
| 22 | svn diff -c1234 > patch.diff |
| 23 | }}} |
| 24 | |
| 25 | 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: |
| 26 | |
| 27 | {{{ |
| 28 | svn diff -r1234:5678 > patch.diff |
| 29 | }}} |
| 30 | |
| 31 | This will include the modifications of all revisions after 1234 up to (and including) 5678. The changes of revision 1234 will not be included. |
| 32 | |
| 33 | == 2) Applying a patch == |
| 34 | |
| 35 | 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). This is done via: |
| 36 | |
| 37 | {{{ |
| 38 | patch -p0 < patch.diff |
| 39 | }}} |
| 40 | |
| 41 | This will apply the changes from the patch file to the current directory. |