Pagine

Tuesday 24 January 2017

SVN tutorial n 27 - patch

The "svn patch" command applies the changes represented in a unidiff patch to the working copy. The synopsis is:
 svn patch <patch_file> [working_copy_patch]
This subcommand will apply changes described a unidiff-formatted patch file <patch_file> to the working copy working_copy_patch. As with most other working copy subcommands, if working_copy_patch is omitted, the changes are applied to the current working directory. A unidiff patch suitable for application to a working copy can be produced with the svn diff command or third-party differencing tools. Any non-unidiff content found in the patch file is ignored.

How to apply a svn patch

Apply a simple patch file generated by the svn diff command. Our patch file will create a new file, delete another file, and modify a third's contents and properties. Here's the patch file itself (which we'll assume is creatively named PATCH):
 cd <your_workingcopy>
 svn patch <path>/PATCH
Sometimes you might need Subversion to interpret a patch “in reverse”—where added things get treated as removed things, and vice-versa. Use the --reverse-diff option for this purpose. In the following example, we'll squirrel away a patch file which describes the changes in our working copy, and then use a reverse patch operation to undo those changes.
 svn diff > PATCH
 svn patch --reverse-diff PATCH

No comments:

Post a Comment