vcs: remove support for CustomBinaryPatchApplier

This commit is contained in:
Aleksey Pivovarov
2018-01-25 18:08:09 +03:00
parent ecbfaf7c78
commit a8241bd82c
9 changed files with 23 additions and 45 deletions
@@ -50,7 +50,7 @@ public abstract class PatchingTestCase extends IntegrationTestCase {
List<FilePatch> patches = new ArrayList<>(reader.readTextPatches());
new PatchApplier<BinaryFilePatch>(myProject, myRoot, patches, null, null, null).execute();
new PatchApplier<BinaryFilePatch>(myProject, myRoot, patches, null, null).execute();
}
protected static void createChildDataWithContent(@NotNull VirtualFile dir, @NotNull String name) {
@@ -209,7 +209,7 @@ public class ApplyPatchTest extends PlatformTestCase {
List<FilePatch> patches = new ArrayList<>(reader.readTextPatches());
ApplyPatchAction.applySkipDirs(patches, skipTopDirs);
final PatchApplier patchApplier = new PatchApplier<BinaryFilePatch>(myProject, patchedDir, patches, null, null, null);
final PatchApplier patchApplier = new PatchApplier<BinaryFilePatch>(myProject, patchedDir, patches, null, null);
ApplyPatchStatus applyStatus = patchApplier.execute(false, false);
assertEquals(expectedStatus, applyStatus);
@@ -15,16 +15,6 @@
*/
package com.intellij.openapi.diff.impl.patch.formove;
import com.intellij.openapi.diff.impl.patch.ApplyPatchStatus;
import com.intellij.openapi.diff.impl.patch.FilePatch;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.util.List;
public interface CustomBinaryPatchApplier<T extends FilePatch> {
@NotNull
ApplyPatchStatus apply(List<PathsVerifier.PatchAndFile> patches) throws IOException;
@NotNull
List<FilePatch> getAppliedPatches();
@Deprecated
public interface CustomBinaryPatchApplier {
}
@@ -56,12 +56,11 @@ import static com.intellij.util.ObjectUtils.chooseNotNull;
/**
* for patches. for shelve.
*/
public class PatchApplier<BinaryType extends FilePatch> {
public class PatchApplier<Unused> {
private static final Logger LOG = Logger.getInstance(PatchApplier.class);
private final Project myProject;
private final VirtualFile myBaseDirectory;
@NotNull private final List<FilePatch> myPatches;
private final CustomBinaryPatchApplier<BinaryType> myCustomForBinaries;
private final CommitContext myCommitContext;
@Nullable private final LocalChangeList myTargetChangeList;
@NotNull private final List<FilePatch> myRemainingPatches;
@@ -76,7 +75,6 @@ public class PatchApplier<BinaryType extends FilePatch> {
@NotNull VirtualFile baseDirectory,
@NotNull List<FilePatch> patches,
@Nullable LocalChangeList targetChangeList,
@Nullable CustomBinaryPatchApplier<BinaryType> customForBinaries,
@Nullable CommitContext commitContext,
boolean reverseConflict,
@Nullable String leftConflictPanelTitle,
@@ -85,7 +83,6 @@ public class PatchApplier<BinaryType extends FilePatch> {
myBaseDirectory = baseDirectory;
myPatches = patches;
myTargetChangeList = targetChangeList;
myCustomForBinaries = customForBinaries;
myCommitContext = commitContext;
myReverseConflict = reverseConflict;
myLeftConflictPanelTitle = leftConflictPanelTitle;
@@ -103,9 +100,18 @@ public class PatchApplier<BinaryType extends FilePatch> {
@NotNull VirtualFile baseDirectory,
@NotNull List<FilePatch> patches,
@Nullable LocalChangeList targetChangeList,
@Nullable CustomBinaryPatchApplier<BinaryType> customForBinaries,
@Nullable CommitContext commitContext) {
this(project, baseDirectory, patches, targetChangeList, customForBinaries, commitContext, false, null, null);
this(project, baseDirectory, patches, targetChangeList, commitContext, false, null, null);
}
@Deprecated
public PatchApplier(@NotNull Project project,
@NotNull VirtualFile baseDirectory,
@NotNull List<FilePatch> patches,
@Nullable LocalChangeList targetChangeList,
@Nullable CustomBinaryPatchApplier ignored,
@Nullable CommitContext commitContext) {
this(project, baseDirectory, patches, targetChangeList, commitContext, false, null, null);
}
@NotNull
@@ -441,17 +447,7 @@ public class PatchApplier<BinaryType extends FilePatch> {
if (status == ApplyPatchStatus.ABORT) return status;
if (myCustomForBinaries == null) {
status = applyList(binaryPatches, context, status, commitContext);
}
else {
ApplyPatchStatus patchStatus = myCustomForBinaries.apply(binaryPatches);
final List<FilePatch> appliedPatches = myCustomForBinaries.getAppliedPatches();
moveForCustomBinaries(binaryPatches, appliedPatches);
status = ApplyPatchStatus.and(status, patchStatus);
myRemainingPatches.removeAll(appliedPatches);
}
status = applyList(binaryPatches, context, status, commitContext);
}
catch (IOException e) {
showError(myProject, e.getMessage());
@@ -460,15 +456,6 @@ public class PatchApplier<BinaryType extends FilePatch> {
return status;
}
private void moveForCustomBinaries(final List<PatchAndFile> patches,
final List<FilePatch> appliedPatches) throws IOException {
for (PatchAndFile patch : patches) {
if (appliedPatches.contains(patch.getApplyPatch().getPatch())) {
myVerifier.doMoveIfNeeded(patch.getFile());
}
}
}
private ApplyPatchStatus applyList(final List<PatchAndFile> patches,
final ApplyPatchContext context,
ApplyPatchStatus status,
@@ -96,7 +96,7 @@ abstract class RevertCommittedStuffAbstractAction extends AnAction implements Du
@Override
public void onSuccess() {
new PatchApplier<BinaryFilePatch>(project, baseDir, patches, chooser.getSelectedList(), null, null).execute();
new PatchApplier<BinaryFilePatch>(project, baseDir, patches, chooser.getSelectedList(), null).execute();
}
});
}
@@ -69,7 +69,8 @@ public class ApplyPatchDefaultExecutor implements ApplyPatchExecutor<AbstractFil
for (VirtualFile base : patchGroups.keySet()) {
appliers.add(new PatchApplier<BinaryFilePatch>(myProject, base,
ContainerUtil
.map(patchGroups.get(base), patchInProgress -> patchInProgress.getPatch()), localList, null, commitContext));
.map(patchGroups.get(base), patchInProgress -> patchInProgress.getPatch()), localList,
commitContext));
}
return appliers;
}
@@ -666,7 +666,7 @@ public class ShelveChangesManager extends AbstractProjectComponent implements JD
ApplicationManager.getApplication().invokeAndWait(() -> {
final PatchApplier<ShelvedBinaryFilePatch> patchApplier =
new PatchApplier<>(myProject, myProject.getBaseDir(),
patches, targetChangeList, null, commitContext, reverse, leftConflictTitle,
patches, targetChangeList, commitContext, reverse, leftConflictTitle,
rightConflictTitle);
patchApplier.execute(showSuccessNotification, systemOperation);
if (isRemoveFilesFromShelf() || systemOperation) {
@@ -214,7 +214,7 @@ public class MergeFromTheirsResolver extends BackgroundTaskGroup {
}
if (patches != null) {
new PatchApplier<BinaryFilePatch>(myVcs.getProject(), myBaseDir, patches, localList, null, null).execute(false, true);
new PatchApplier<BinaryFilePatch>(myVcs.getProject(), myBaseDir, patches, localList, null).execute(false, true);
myThereAreCreations =
patches.stream().anyMatch(patch -> patch.isNewFile() || !Comparing.equal(patch.getAfterName(), patch.getBeforeName()));
}
@@ -73,7 +73,7 @@ public class ConflictCreator {
}
if (! filePatchList.isEmpty()) {
PatchApplier<BinaryFilePatch> applier = new PatchApplier<>(myProject, myTheirsDir, filePatchList, (LocalChangeList)null, null, null);
PatchApplier<BinaryFilePatch> applier = new PatchApplier<>(myProject, myTheirsDir, filePatchList, (LocalChangeList)null, null);
applier.setIgnoreContentRootsCheck();
applier.execute();
Assert.assertEquals(0, applier.getRemainingPatches().size());