public static void validateAndWritePatchToFile(@NotNull Project project,
                                                   @NotNull Path baseDir,
                                                   @NotNull Collection<? extends Change> changes,
                                                   @Nullable String commitMessage,
                                                   boolean reversePatch,
                                                   @NotNull Path file,
                                                   @NotNull Charset encoding,
                                                   @NotNull PatchBuilder patchBuilder,
                                                   @NotNull CommitContext commitContext) throws VcsException, IOException {
      if (!checkIsFileValid(project, file)) {
        return;
      }

      Files.createDirectories(file.getParent());
      VcsConfiguration.getInstance(project).acceptLastCreatedPatchName(file.getFileName().toString());
      String patchPath = FileUtil.toSystemIndependentName(StringUtil.notNullize(file.getParent().toString()));
      String valueToStore = StringUtil.isEmpty(patchPath) || patchPath.equals(getDefaultPatchPath(project)) ? null : patchPath;
      PropertiesComponent.getInstance(project).setValue(VCS_PATCH_PATH_KEY, valueToStore);
      VcsApplicationSettings.getInstance().PATCH_STORAGE_LOCATION = valueToStore;

      List<FilePatch> patches = patchBuilder.buildPatches(baseDir, changes, reversePatch, true);
      PatchWriter.writePatches(project, file, baseDir, patches, commitMessage, commitContext, encoding);

      WaitForProgressToShow.runOrInvokeLaterAboveProgress(() -> {
        final VcsConfiguration configuration = VcsConfiguration.getInstance(project);
        if (Boolean.TRUE.equals(configuration.SHOW_PATCH_IN_EXPLORER)) {
          RevealFileAction.openFile(file);
        }
        else if (configuration.SHOW_PATCH_IN_EXPLORER == null) {
          configuration.SHOW_PATCH_IN_EXPLORER = showDialog(project, file);
        }
      }, null, project);
    }
public static void validateAndWritePatchToFile(@NotNull Project project,
                                                   @NotNull Path baseDir,
                                                   @NotNull Collection<? extends Change> changes,
                                                   @Nullable String commitMessage,
                                                   boolean reversePatch,
                                                   @NotNull Path file,
                                                   @NotNull Charset encoding,
                                                   @NotNull PatchBuilder patchBuilder,
                                                   @NotNull CommitContext commitContext)