Search in sources :

Example 1 with ApplyPatchContext

use of com.intellij.openapi.diff.impl.patch.ApplyPatchContext in project intellij-community by JetBrains.

the class PatchApplier method actualApply.

@Nullable
private ApplyPatchStatus actualApply(final List<Pair<VirtualFile, ApplyTextFilePatch>> textPatches, final List<Pair<VirtualFile, ApplyFilePatchBase<BinaryType>>> binaryPatches, final CommitContext commitContext) {
    final ApplyPatchContext context = new ApplyPatchContext(myBaseDirectory, 0, true, true);
    ApplyPatchStatus status;
    try {
        status = applyList(textPatches, context, null, commitContext);
        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);
        }
    } catch (IOException e) {
        showError(myProject, e.getMessage());
        return ApplyPatchStatus.ABORT;
    }
    return status;
}
Also used : ApplyPatchContext(com.intellij.openapi.diff.impl.patch.ApplyPatchContext) ApplyPatchStatus(com.intellij.openapi.diff.impl.patch.ApplyPatchStatus) IOException(java.io.IOException) ApplyTextFilePatch(com.intellij.openapi.diff.impl.patch.apply.ApplyTextFilePatch) FilePatch(com.intellij.openapi.diff.impl.patch.FilePatch) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ApplyPatchContext (com.intellij.openapi.diff.impl.patch.ApplyPatchContext)1 ApplyPatchStatus (com.intellij.openapi.diff.impl.patch.ApplyPatchStatus)1 FilePatch (com.intellij.openapi.diff.impl.patch.FilePatch)1 ApplyTextFilePatch (com.intellij.openapi.diff.impl.patch.apply.ApplyTextFilePatch)1 IOException (java.io.IOException)1 Nullable (org.jetbrains.annotations.Nullable)1