PyCharm 3.1.0 Web Help

Postponed changes, stored in a patch file, can be applied to the target file or directory later. If source code has been edited after creating the patch, conflicts can arise. PyCharm suggests a handy way to resolve such conflicts and merge patch with the results of editing.

When a patch is opened, PyCharm detects files with the same names as the names of the modified files. For each detected file, PyCharm compares the paths to it relative to the base directory, with the path from the patch, and chooses the closest match. If no matching path is found, the file is considered located in the project base directory and highlighted red.

You can apply changes to the files stored in the other locations than those specified in the patch, by mapping an arbitrary directory as the base one, or stripping off the leading directories.

To apply a patch
  1. On the main menu, choose VCS | Apply patch.
  2. In the Apply Patch dialog box that opens, specify the fully qualified name of the patch file. Type the name manually in the Patch file name text box or click the Browse button browseButton.png and locate the desired patch file using Select Patch File dialog box.
  3. Configure the patch presentation layout. To have changes shown in a flat view, press the Group by Directory toolbar button vcsToolbarGroupByDirIcon.gif.
    Release the button to have changes shown in a directory tree view.
  4. To have a change applied, select the check box next to it.
  5. To have a change applied to a modified file that has been moved to another location, specify the new file location.
    • To map another base directory, select the desired file, directory, or a group files/directories and click the Map base directory toolbar button icon_vcs_basic_directory.png. In the dialog that opens choose the directory relative to which file names will be interpreted.
    • To remove leading directories from the path, click the Strip Directory toolbar button icon_vcs_strip_directory.png as many times as many leading directories you need to strip. The number of removed slashes is indicated in square brackets.
    • To revert the last strip directory action, click the Restore Directory toolbar button icon_vcs_restore_directory.png. Click the button as many times as many previously stripped leading directories you need to restore.
    • To revert all the strip directory actions in the selection, click the Reset Directories toolbar button icon_vcs_reset_directories.png.
    • To have all the leading directories stripped and have the changes applied to the file with the specified name in the base directory, click the Remove Directories toolbar button icon_vcs_remove_directories.png.
  6. To view the differences and possible conflicts between your local working copy, the repository version, and the patch in the Differences Viewer, select the desired change and click the Show Differences button vcsToolbarCompareIcon.gif.

  7. To resolve conflicts between the patched and the current versions, if any, in both versions select the changes to be merged to the resulting file, and then click Apply.

See Also




Web Resources: