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;
}
Aggregations