mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Remove unused logic of populating exceptions list
It used to show errors from the list later, but that does't happen anymore. Show error manually when needed. In addition to that move tagging process to the modal task instead of freezing the UI.
This commit is contained in:
@@ -18,7 +18,6 @@ package git4idea.actions;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import git4idea.GitUtil;
|
||||
import git4idea.GitVcs;
|
||||
@@ -38,8 +37,7 @@ public class GitFetch extends GitRepositoryAction {
|
||||
|
||||
protected void perform(@NotNull final Project project,
|
||||
@NotNull final List<VirtualFile> gitRoots,
|
||||
@NotNull final VirtualFile defaultRoot,
|
||||
final List<VcsException> exceptions) throws VcsException {
|
||||
@NotNull final VirtualFile defaultRoot) {
|
||||
GitVcs.runInBackground(new Task.Backgroundable(project, "Fetching...", true) {
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
|
||||
@@ -64,8 +64,7 @@ abstract class GitMergeAction extends GitRepositoryAction {
|
||||
|
||||
protected void perform(@NotNull final Project project,
|
||||
@NotNull final List<VirtualFile> gitRoots,
|
||||
@NotNull final VirtualFile defaultRoot,
|
||||
final List<VcsException> exceptions) throws VcsException {
|
||||
@NotNull final VirtualFile defaultRoot) {
|
||||
final DialogState dialogState = displayDialog(project, gitRoots, defaultRoot);
|
||||
if (dialogState == null) {
|
||||
return;
|
||||
|
||||
@@ -34,7 +34,6 @@ import org.jetbrains.annotations.CalledInAwt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.intellij.util.ObjectUtils.notNull;
|
||||
@@ -54,13 +53,7 @@ public abstract class GitRepositoryAction extends DumbAwareAction {
|
||||
|
||||
final VirtualFile defaultRoot = getDefaultRoot(project, roots, e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY));
|
||||
|
||||
List<VcsException> exceptions = new ArrayList<>();
|
||||
try {
|
||||
perform(project, roots, defaultRoot, exceptions);
|
||||
}
|
||||
catch (VcsException ex) {
|
||||
exceptions.add(ex);
|
||||
}
|
||||
perform(project, roots, defaultRoot);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -128,13 +121,11 @@ public abstract class GitRepositoryAction extends DumbAwareAction {
|
||||
* @param project a context project
|
||||
* @param gitRoots a git roots that affect the current project (sorted by {@link VirtualFile#getPresentableUrl()})
|
||||
* @param defaultRoot a guessed default root (based on the currently selected file list)
|
||||
* @param exceptions a list of exceptions from running git
|
||||
* @throws VcsException if there is a problem with running git (this exception is considered to be added to the end of the exception list)
|
||||
*/
|
||||
protected abstract void perform(@NotNull Project project,
|
||||
@NotNull List<VirtualFile> gitRoots,
|
||||
@NotNull VirtualFile defaultRoot,
|
||||
List<VcsException> exceptions) throws VcsException;
|
||||
@NotNull VirtualFile defaultRoot);
|
||||
|
||||
@Override
|
||||
public void update(final AnActionEvent e) {
|
||||
|
||||
@@ -18,7 +18,6 @@ package git4idea.actions;
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import git4idea.GitUtil;
|
||||
@@ -48,8 +47,7 @@ public class GitResetHead extends GitRepositoryAction {
|
||||
*/
|
||||
protected void perform(@NotNull Project project,
|
||||
@NotNull List<VirtualFile> gitRoots,
|
||||
@NotNull VirtualFile defaultRoot,
|
||||
List<VcsException> exceptions) throws VcsException {
|
||||
@NotNull VirtualFile defaultRoot) {
|
||||
GitResetDialog d = new GitResetDialog(project, gitRoots, defaultRoot);
|
||||
if (!d.showAndGet()) {
|
||||
return;
|
||||
@@ -65,6 +63,8 @@ public class GitResetHead extends GitRepositoryAction {
|
||||
GitRepositoryManager manager = GitUtil.getRepositoryManager(project);
|
||||
manager.updateRepository(d.getGitRoot());
|
||||
VfsUtil.markDirtyAndRefresh(true, true, false, d.getGitRoot());
|
||||
showErrors(project, getActionName(), exceptions);
|
||||
if(!h.errors().isEmpty()) {
|
||||
showErrors(project, getActionName(), h.errors());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ package git4idea.actions;
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManager;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -40,8 +39,7 @@ public class GitStash extends GitRepositoryAction {
|
||||
*/
|
||||
protected void perform(@NotNull final Project project,
|
||||
@NotNull final List<VirtualFile> gitRoots,
|
||||
@NotNull final VirtualFile defaultRoot,
|
||||
final List<VcsException> exceptions) throws VcsException {
|
||||
@NotNull final VirtualFile defaultRoot) {
|
||||
final ChangeListManager changeListManager = ChangeListManager.getInstance(project);
|
||||
if (changeListManager.isFreezedWithNotification("Can not stash changes now")) return;
|
||||
GitStashDialog d = new GitStashDialog(project, gitRoots, defaultRoot);
|
||||
@@ -58,7 +56,9 @@ public class GitStash extends GitRepositoryAction {
|
||||
DvcsUtil.workingTreeChangeFinished(project, token);
|
||||
}
|
||||
VfsUtil.markDirtyAndRefresh(false, true, false, root);
|
||||
showErrors(project, getActionName(), exceptions);
|
||||
if(!h.errors().isEmpty()) {
|
||||
showErrors(project, getActionName(), h.errors());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,8 +15,9 @@
|
||||
*/
|
||||
package git4idea.actions;
|
||||
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import git4idea.i18n.GitBundle;
|
||||
import git4idea.ui.GitTagDialog;
|
||||
@@ -42,13 +43,15 @@ public class GitTag extends GitRepositoryAction {
|
||||
*/
|
||||
protected void perform(@NotNull final Project project,
|
||||
@NotNull final List<VirtualFile> gitRoots,
|
||||
@NotNull final VirtualFile defaultRoot,
|
||||
final List<VcsException> exceptions) throws VcsException {
|
||||
@NotNull final VirtualFile defaultRoot) {
|
||||
GitTagDialog d = new GitTagDialog(project, gitRoots, defaultRoot);
|
||||
if (!d.showAndGet()) {
|
||||
return;
|
||||
if (d.showAndGet()) {
|
||||
new Task.Modal(project, "Tagging...", true) {
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
d.runAction();
|
||||
}
|
||||
}.queue();
|
||||
}
|
||||
d.runAction(exceptions);
|
||||
showErrors(project, getActionName(), exceptions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package git4idea.actions;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManager;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import git4idea.i18n.GitBundle;
|
||||
@@ -43,8 +42,7 @@ public class GitUnstash extends GitRepositoryAction {
|
||||
*/
|
||||
protected void perform(@NotNull final Project project,
|
||||
@NotNull final List<VirtualFile> gitRoots,
|
||||
@NotNull final VirtualFile defaultRoot,
|
||||
final List<VcsException> exceptions) throws VcsException {
|
||||
@NotNull final VirtualFile defaultRoot) {
|
||||
final ChangeListManager changeListManager = ChangeListManager.getInstance(project);
|
||||
if (changeListManager.isFreezedWithNotification("Can not unstash changes now")) return;
|
||||
GitUnstashDialog.showUnstashDialog(project, gitRoots, defaultRoot);
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.VcsNotifier;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -156,10 +155,8 @@ public class GitTagDialog extends DialogWrapper {
|
||||
|
||||
/**
|
||||
* Perform tagging according to selected options
|
||||
*
|
||||
* @param exceptions the list where exceptions are collected
|
||||
*/
|
||||
public void runAction(final List<VcsException> exceptions) {
|
||||
public void runAction() {
|
||||
final String message = myMessageTextArea.getText();
|
||||
final boolean hasMessage = message.trim().length() != 0;
|
||||
final File messageFile;
|
||||
@@ -200,20 +197,18 @@ public class GitTagDialog extends DialogWrapper {
|
||||
if (object.length() != 0) {
|
||||
h.addParameters(object);
|
||||
}
|
||||
try {
|
||||
GitHandlerUtil.doSynchronously(h, GitBundle.getString("tagging.title"), h.printableCommandLine());
|
||||
VcsNotifier.getInstance(myProject).notifySuccess(myTagNameTextField.getText(),
|
||||
"Created tag " + myTagNameTextField.getText() + " successfully.");
|
||||
GitRepository repository = GitUtil.getRepositoryManager(myProject).getRepositoryForRoot(getGitRoot());
|
||||
if (repository != null) {
|
||||
repository.getRepositoryFiles().refresh(true);
|
||||
}
|
||||
else {
|
||||
LOG.error("No repository registered for root: " + getGitRoot());
|
||||
}
|
||||
GitHandlerUtil.doSynchronously(h, GitBundle.getString("tagging.title"), h.printableCommandLine());
|
||||
VcsNotifier.getInstance(myProject).notifySuccess(myTagNameTextField.getText(),
|
||||
"Created tag " + myTagNameTextField.getText() + " successfully.");
|
||||
GitRepository repository = GitUtil.getRepositoryManager(myProject).getRepositoryForRoot(getGitRoot());
|
||||
if (repository != null) {
|
||||
repository.getRepositoryFiles().refresh(true);
|
||||
}
|
||||
finally {
|
||||
exceptions.addAll(h.errors());
|
||||
else {
|
||||
LOG.error("No repository registered for root: " + getGitRoot());
|
||||
}
|
||||
if(!h.errors().isEmpty()) {
|
||||
GitUIUtil.notifyImportantError(myProject, "Error rebasing", GitUIUtil.stringifyErrors(h.errors()));
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
||||
Reference in New Issue
Block a user