Search in sources :

Example 1 with TextFilePatchInProgress

use of com.intellij.openapi.vcs.changes.patch.TextFilePatchInProgress in project intellij-community by JetBrains.

the class ApplyPatchSaveToFileExecutor method toOnePatchGroup.

@NotNull
public static List<FilePatch> toOnePatchGroup(@NotNull MultiMap<VirtualFile, TextFilePatchInProgress> patchGroups, @NotNull VirtualFile newPatchBase) throws IOException {
    List<FilePatch> result = newArrayList();
    for (Map.Entry<VirtualFile, Collection<TextFilePatchInProgress>> entry : patchGroups.entrySet()) {
        VirtualFile oldPatchBase = entry.getKey();
        String relativePath = VfsUtilCore.getRelativePath(oldPatchBase, newPatchBase, '/');
        boolean toConvert = !isEmptyOrSpaces(relativePath) && !".".equals(relativePath);
        for (TextFilePatchInProgress patchInProgress : entry.getValue()) {
            TextFilePatch patch = patchInProgress.getPatch();
            if (toConvert) {
                patch.setBeforeName(getNewBaseRelativePath(newPatchBase, oldPatchBase, patch.getBeforeName()));
                patch.setAfterName(getNewBaseRelativePath(newPatchBase, oldPatchBase, patch.getAfterName()));
            }
            result.add(patch);
        }
    }
    return result;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) TextFilePatchInProgress(com.intellij.openapi.vcs.changes.patch.TextFilePatchInProgress) Collection(java.util.Collection) TextFilePatch(com.intellij.openapi.diff.impl.patch.TextFilePatch) FilePatch(com.intellij.openapi.diff.impl.patch.FilePatch) Map(java.util.Map) MultiMap(com.intellij.util.containers.MultiMap) TextFilePatch(com.intellij.openapi.diff.impl.patch.TextFilePatch) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

FilePatch (com.intellij.openapi.diff.impl.patch.FilePatch)1 TextFilePatch (com.intellij.openapi.diff.impl.patch.TextFilePatch)1 TextFilePatchInProgress (com.intellij.openapi.vcs.changes.patch.TextFilePatchInProgress)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 MultiMap (com.intellij.util.containers.MultiMap)1 Collection (java.util.Collection)1 Map (java.util.Map)1 NotNull (org.jetbrains.annotations.NotNull)1