From 437dc657ed56b7acb8bec15759e723b36ad0260a Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Fri, 24 May 2024 20:42:50 +0200 Subject: [PATCH] [lvcs] cleanup: move utility method and remove class GitOrigin-RevId: d3e3fdddc689e3288618ab98f71fe7d3d936f98e --- platform/lvcs-impl/api-dump-unreviewed.txt | 3 --- .../integration/patches/PatchCreator.java | 26 ------------------- .../CreateIncrementalCompilationBackup.kt | 18 ++++++++++--- 3 files changed, 15 insertions(+), 32 deletions(-) delete mode 100644 platform/lvcs-impl/src/com/intellij/history/integration/patches/PatchCreator.java diff --git a/platform/lvcs-impl/api-dump-unreviewed.txt b/platform/lvcs-impl/api-dump-unreviewed.txt index 587d14ef0b7c..f491e47facaa 100644 --- a/platform/lvcs-impl/api-dump-unreviewed.txt +++ b/platform/lvcs-impl/api-dump-unreviewed.txt @@ -513,9 +513,6 @@ f:com.intellij.history.integration.ValidateHistoryAction - actionPerformed(com.intellij.openapi.actionSystem.AnActionEvent):V - getActionUpdateThread():com.intellij.openapi.actionSystem.ActionUpdateThread - update(com.intellij.openapi.actionSystem.AnActionEvent):V -f:com.intellij.history.integration.patches.PatchCreator -- ():V -- s:create(com.intellij.openapi.project.Project,java.util.List,java.nio.file.Path,Z,com.intellij.openapi.vcs.changes.CommitContext):V f:com.intellij.history.integration.revertion.DifferenceReverter - com.intellij.history.integration.revertion.Reverter - (com.intellij.openapi.project.Project,com.intellij.history.core.LocalHistoryFacade,com.intellij.history.integration.IdeaGateway,java.util.List,com.intellij.history.core.revisions.Revision):V diff --git a/platform/lvcs-impl/src/com/intellij/history/integration/patches/PatchCreator.java b/platform/lvcs-impl/src/com/intellij/history/integration/patches/PatchCreator.java deleted file mode 100644 index 81ff40bf9ed9..000000000000 --- a/platform/lvcs-impl/src/com/intellij/history/integration/patches/PatchCreator.java +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -package com.intellij.history.integration.patches; - -import com.intellij.openapi.diff.impl.patch.FilePatch; -import com.intellij.openapi.diff.impl.patch.IdeaTextPatchBuilder; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.vcs.VcsException; -import com.intellij.openapi.vcs.changes.Change; -import com.intellij.openapi.vcs.changes.CommitContext; -import com.intellij.openapi.vcs.changes.patch.PatchWriter; -import com.intellij.project.ProjectKt; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.io.IOException; -import java.nio.file.Path; -import java.util.List; - -public final class PatchCreator { - public static void create(@NotNull Project project, @NotNull List changes, @NotNull Path file, boolean isReverse, @Nullable CommitContext commitContext) - throws IOException, VcsException { - Path basePath = ProjectKt.getStateStore(project).getProjectBasePath(); - List patches = IdeaTextPatchBuilder.buildPatch(project, changes, basePath, isReverse, false); - PatchWriter.writePatches(project, file, basePath, patches, commitContext); - } -} diff --git a/plugins/kotlin/jvm/src/org/jetbrains/kotlin/idea/internal/makeBackup/CreateIncrementalCompilationBackup.kt b/plugins/kotlin/jvm/src/org/jetbrains/kotlin/idea/internal/makeBackup/CreateIncrementalCompilationBackup.kt index 5991127660f5..1fb901ecbb8f 100644 --- a/plugins/kotlin/jvm/src/org/jetbrains/kotlin/idea/internal/makeBackup/CreateIncrementalCompilationBackup.kt +++ b/plugins/kotlin/jvm/src/org/jetbrains/kotlin/idea/internal/makeBackup/CreateIncrementalCompilationBackup.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.kotlin.idea.internal.makeBackup @@ -6,13 +6,13 @@ import com.intellij.compiler.server.BuildManager import com.intellij.history.core.RevisionsCollector import com.intellij.history.core.revisions.Revision.getDifferencesBetween import com.intellij.history.integration.LocalHistoryImpl -import com.intellij.history.integration.patches.PatchCreator import com.intellij.ide.IdeBundle import com.intellij.ide.actions.RevealFileAction import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.application.PathManager import com.intellij.openapi.application.runReadAction +import com.intellij.openapi.diff.impl.patch.IdeaTextPatchBuilder import com.intellij.openapi.progress.ProgressIndicator import com.intellij.openapi.progress.ProgressManager import com.intellij.openapi.progress.Task @@ -20,12 +20,17 @@ import com.intellij.openapi.project.Project import com.intellij.openapi.ui.MessageDialogBuilder.Companion.okCancel import com.intellij.openapi.ui.Messages import com.intellij.openapi.util.io.FileUtil +import com.intellij.openapi.vcs.VcsException import com.intellij.openapi.vcs.changes.Change +import com.intellij.openapi.vcs.changes.patch.PatchWriter +import com.intellij.project.stateStore import com.intellij.util.WaitForProgressToShow import com.intellij.util.io.ZipUtil import org.jetbrains.kotlin.idea.KotlinJvmBundle import java.io.File import java.io.FileOutputStream +import java.io.IOException +import java.nio.file.Path import java.text.SimpleDateFormat import java.util.* import java.util.zip.ZipOutputStream @@ -96,7 +101,7 @@ class CreateIncrementalCompilationBackup : AnAction(KotlinJvmBundle.message("cre Change(d.getLeftContentRevision(gateway), d.getRightContentRevision(gateway)) } - PatchCreator.create(project, changes, patchFile.toPath(), false, null) + createPatch(project, changes, patchFile.toPath(), false) if (++patchesCreated >= PATCHES_TO_CREATE) { break @@ -106,6 +111,13 @@ class CreateIncrementalCompilationBackup : AnAction(KotlinJvmBundle.message("cre } } + @Throws(IOException::class, VcsException::class) + private fun createPatch(project: Project, changes: List, file: Path, isReverse: Boolean) { + val basePath = project.stateStore.projectBasePath + val patches = IdeaTextPatchBuilder.buildPatch(project, changes, basePath, isReverse, false) + PatchWriter.writePatches(project, file, basePath, patches, null) + } + private fun copyLogs(backupDir: File, indicator: ProgressIndicator) { indicator.text = KotlinJvmBundle.message("copying.logs") indicator.fraction = PATCHES_FRACTION