MPS 2018.2 Help

Using Patches

Instead of committing your changes, you can put them in a .patch file that you can apply to your sources later, or send by email, etc.

Create a patch

To create a patch based on uncommitted changes, do the following:

  1. Open the Version Control tool window (N/A) and switch to the Local Changes tab.
  2. Select a file or a changelist based on which you want to create a patch.
  3. Select Create Patch from the context menu or from the main VCS menu.
  4. In the dialog that opens, make sure that all changes you want to include in the patch are selected, enter a commit comment (optionally) and click Create Patch.
  5. In the Patch File Settings dialog, modify the default patch file location if necessary, and click OK.

If you do not need to save a patch to a file, and want, for example, to send it by email or through a messenger, you can select Copy as Patch to Clipboard from the context menu of the selected file or changelist, and then paste it to a message body.

You can also create a patch based on changes that have already been committed. To create a patch from an entire commit, locate it in the Log view, and select Create Patch from the context menu. If you need to create a patch on a single file, and the corresponding commit contains multiple files, do the following:

  1. Select the required file in any view (in the Project tool window, in the editor, in the Local Changes tab of the Version Control tool window, etc.).
  2. Select Git | Show History from the main VCS menu or from the context menu of the selection. The History tab is added to the Version Control tool window.
  3. Right-click a revision and choose Create Patch from the context menu, or click the Create Patch icon icons vcs patch svg on the toolbar.

Apply a patch

To apply changes stored in a file to your sources, do the following:

  1. Select VCS | Apply patch from the main menu.
  2. In the Apply Patch dialog that opens, specify the path to the .patch file you want to apply.
  3. If necessary, click the Map base directory icon icons vcs mapBase to specify a directory relative to which file names in the patch file will be interpreted. You can map a base directory to a single file, directory, or to a selection.
  4. If the source code was edited after a patch was created, conflicts may arise. To check if you patch can be applied without conflicts, click the Show Diff icon icons actions diff svg or press N/A. If there are conflicts, the corresponding lines will be highlighted in red.
  5. If you want to apply changes to files stored in different locations from those specified in the patch, you can strip off the leading directories by using the Strip Directory button icons vcs stripDown.
  6. Select an existing changelist where you want to add the patch from the drop-down list, or specify the name of a new changelist in the Name field, and, optionally, enter a comment to this changelist.
  7. If you want to make this changelist active, select the Set active option.

You can also copy a patch file content and apply it by choosing VCS | Apply Patch from Clipboard from the main menu. This is convenient when you receive a patch by email, for example, and do not want to save it. For Git format patches, MPS extracts the commit message and the author and automatically fills the corresponding fields in the Commit Changes dialog.

Last modified: 13 August 2018