mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
shelf: cleanup - reuse existing method and optimize error notifications
This commit is contained in:
+5
-5
@@ -692,11 +692,11 @@ public class ShelveChangesManager implements JDOMExternalizable, ProjectComponen
|
||||
});
|
||||
}
|
||||
|
||||
private static List<TextFilePatch> loadTextPatches(final Project project,
|
||||
final ShelvedChangeList changeList,
|
||||
final List<ShelvedChange> changes,
|
||||
final List<FilePatch> remainingPatches,
|
||||
final CommitContext commitContext)
|
||||
static List<TextFilePatch> loadTextPatches(final Project project,
|
||||
final ShelvedChangeList changeList,
|
||||
final List<ShelvedChange> changes,
|
||||
final List<FilePatch> remainingPatches,
|
||||
final CommitContext commitContext)
|
||||
throws IOException, PatchSyntaxException {
|
||||
final List<TextFilePatch> textFilePatches = loadPatches(project, changeList.PATH, commitContext);
|
||||
|
||||
|
||||
+16
-25
@@ -59,6 +59,7 @@ import com.intellij.util.ui.GraphicsUtil;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import com.intellij.util.ui.update.MergingUpdateQueue;
|
||||
import com.intellij.util.ui.update.Update;
|
||||
import com.intellij.vcsUtil.VcsImplUtil;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import one.util.streamex.StreamEx;
|
||||
import org.jetbrains.annotations.CalledInAwt;
|
||||
@@ -676,37 +677,27 @@ public class ShelvedChangesViewManager implements Disposable {
|
||||
}
|
||||
|
||||
private void removeChangesFromChangeList(@NotNull Project project,
|
||||
@NotNull ShelvedChangeList list,
|
||||
@NotNull List<ShelvedChange> changes,
|
||||
@NotNull List<ShelvedBinaryFile> binaryFiles) {
|
||||
final ArrayList<ShelvedBinaryFile> oldBinaries = new ArrayList<>(list.getBinaryFiles());
|
||||
final ArrayList<ShelvedChange> oldChanges = new ArrayList<>(list.getChanges(project));
|
||||
|
||||
oldBinaries.removeAll(binaryFiles);
|
||||
oldChanges.removeAll(changes);
|
||||
@NotNull ShelvedChangeList list,
|
||||
@NotNull List<ShelvedChange> changes,
|
||||
@NotNull List<ShelvedBinaryFile> binaryFiles) {
|
||||
final ArrayList<ShelvedBinaryFile> remainingBinaries = new ArrayList<>(list.getBinaryFiles());
|
||||
remainingBinaries.removeAll(binaryFiles);
|
||||
|
||||
final CommitContext commitContext = new CommitContext();
|
||||
final List<FilePatch> patches = new ArrayList<>();
|
||||
final List<VcsException> exceptions = new ArrayList<>();
|
||||
for (ShelvedChange change : oldChanges) {
|
||||
try {
|
||||
patches.add(change.loadFilePatch(myProject, commitContext));
|
||||
}
|
||||
catch (IOException | PatchSyntaxException e) {
|
||||
exceptions.add(new VcsException(e));
|
||||
}
|
||||
final List<FilePatch> remainingPatches = new ArrayList<>();
|
||||
try {
|
||||
ShelveChangesManager.loadTextPatches(myProject, list, changes, remainingPatches, commitContext);
|
||||
}
|
||||
if (patches.isEmpty() && oldBinaries.isEmpty()) {
|
||||
catch (IOException | PatchSyntaxException e) {
|
||||
LOG.info(e);
|
||||
VcsImplUtil.showErrorMessage(myProject, e.getMessage(), "Cannot delete files from " + list.DESCRIPTION);
|
||||
return;
|
||||
}
|
||||
if (remainingPatches.isEmpty() && remainingBinaries.isEmpty()) {
|
||||
myShelveChangesManager.deleteChangeList(list);
|
||||
}
|
||||
else {
|
||||
myShelveChangesManager.saveRemainingPatches(list, patches, oldBinaries, commitContext, true);
|
||||
}
|
||||
|
||||
if (! exceptions.isEmpty()) {
|
||||
String title = list.DESCRIPTION == null ? "" : list.DESCRIPTION;
|
||||
title = title.substring(0, Math.min(10, title.length()));
|
||||
AbstractVcsHelper.getInstance(myProject).showErrors(exceptions, "Deleting files from '" + title + "'");
|
||||
myShelveChangesManager.saveRemainingPatches(list, remainingPatches, remainingBinaries, commitContext, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user