Create Patches

Let's suppose you are working to a set of XML files, that you distribute to other people. From time to time you are tagging the project and distribute the releases. If you continue working for a period correcting problems, you may find yourself in the situations to notify your users that you have corrected a problem. In this case you may prefer to distribute them a patch, a collection of differences that applied over the last distribution would correct the problem. The SVN client creates the patch in the Unified Diff format.

Creating patches in Subversion implies the access to two states (revisions) of a project. If you have not committed yet your current working copy and prefer not to do it, it is possible to create a patch between the current working copy and a revision from the repository. If you want to create a patch between two revisions that are already committed to the repository that is also possible.

In order to create the patch, you will use the action from the submenu Modify of the contextual menu of the Working Copy view: Create Patch. This opens the Create patch wizard.

Figure 3.44. The Create patch wizard - step 1

The Create patch wizard - step 1

In the first step of the wizard you select the type of the patch: a patch between working copy and repository revision or a patch between two repository revisions. The Next button moves the wizard to the second step.

Create a patch from working copy

In case of the first type of patch in this step you specify the revision of the repository for finding the patch between the working copy and the repository. The revision can be HEAD or a revision number selected from the list of all revisions committed to the repository.

Figure 3.45. Patch between working copy and repository - step 2

Patch between working copy and repository - step 2

In the next step the following options can be specified:

Figure 3.46. Patch between working copy and repository - step 3

Patch between working copy and repository - step 3

Patch depth

The depth of recursive folders included in the patch. If the patch is created only for a file then the depth is always zero. The depth can have one of the values:

Current depth

The depth of going into the folder for creating the patch is the same as the depth of that folder in the working copy.

Recursive (infinity)

The patch is created on all the files and folders contained in the selected folder.

Immediate children (immediates)

The patch is created only on the child files and folders without going in subfolders.

File children only (files)

The patch is created only on the child files.

This folder only (empty)

The patch is created only on the selected folder (that is no child file or folder is included in the patch).

Ignore ancestry

The SVN ancestry that may exist when the two URLs specified for creating the patch have a common SVN history is ignored when the patch is created.

Ignore line endings

The differences in line endings are ignored when the patch is created.

Ignore whitespaces

The differences in whitespaces are ignored when the patch is created.

Save in clipboard

The patch will be created and saved in clipboard.

Save in file

The patch will be created and saved in the specified file.

Include unversioned files in the patch

In the next step you can specify the unversioned files that will be included in the generated patch. If the patch is applied on a folder of the working copy and that folder contains unversioned files this step of the wizard offers the option of selecting the ones that will be included in the patch.

Figure 3.47. Patch between working copy and repository - step 4

Patch between working copy and repository - step 4