From 6cab49fbb2cea2c72c1bc110f41169f549ce4da4 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Wed, 8 Jun 2011 14:35:32 +0400 Subject: [PATCH] IDEA-69853 GitRebaser to use the ProgressIndicator if one is available. [Reviewed by irengrig] --- .../git4idea/checkin/GitPushActiveBranchesDialog.java | 3 ++- plugins/git4idea/src/git4idea/rebase/GitRebaser.java | 9 ++++++++- .../git4idea/src/git4idea/update/GitRebaseUpdater.java | 2 +- .../git4idea/src/git4idea/update/GitUpdateProcess.java | 2 +- .../tests/rebase/GitRebaserReorderCommitsTest.java | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/plugins/git4idea/src/git4idea/checkin/GitPushActiveBranchesDialog.java b/plugins/git4idea/src/git4idea/checkin/GitPushActiveBranchesDialog.java index 15c8ce9bef24..e770b9ab3f7c 100644 --- a/plugins/git4idea/src/git4idea/checkin/GitPushActiveBranchesDialog.java +++ b/plugins/git4idea/src/git4idea/checkin/GitPushActiveBranchesDialog.java @@ -456,6 +456,7 @@ public class GitPushActiveBranchesDialog extends DialogWrapper { final Boolean[] result = new Boolean[1]; result[0] = false; + final ProgressIndicator finalProgressIndicator = progressIndicator; new GitUpdateLikeProcess(myProject) { @Override protected void runImpl(ContinuationContext context) { @@ -464,7 +465,7 @@ public class GitPushActiveBranchesDialog extends DialogWrapper { saver.saveLocalChanges(rootsToReorder); try { - GitRebaser rebaser = new GitRebaser(myProject); + GitRebaser rebaser = new GitRebaser(myProject, finalProgressIndicator); for (Map.Entry> rootToCommits: rebaseInfo.reorderedCommits.entrySet()) { final VirtualFile root = rootToCommits.getKey(); GitBranch b = GitBranch.current(myProject, root); diff --git a/plugins/git4idea/src/git4idea/rebase/GitRebaser.java b/plugins/git4idea/src/git4idea/rebase/GitRebaser.java index 9d9682969640..c016ca13d0bf 100644 --- a/plugins/git4idea/src/git4idea/rebase/GitRebaser.java +++ b/plugins/git4idea/src/git4idea/rebase/GitRebaser.java @@ -16,6 +16,7 @@ package git4idea.rebase; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vcs.ProjectLevelVcsManager; @@ -27,6 +28,7 @@ import git4idea.commands.*; import git4idea.merge.GitMergeConflictResolver; import git4idea.ui.GitUIUtil; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.io.File; import java.io.FileOutputStream; @@ -44,9 +46,11 @@ public class GitRebaser { private GitVcs myVcs; private List mySkippedCommits; private static final Logger LOG = Logger.getInstance(GitRebaser.class); + private final @Nullable ProgressIndicator myProgressIndicator; - public GitRebaser(Project project) { + public GitRebaser(Project project, ProgressIndicator progressIndicator) { myProject = project; + myProgressIndicator = progressIndicator; myVcs = GitVcs.getInstance(project); mySkippedCommits = new ArrayList(); } @@ -56,6 +60,7 @@ public class GitRebaser { final GitLineHandler rh = new GitLineHandler(myProject, root, GitCommand.REBASE); rh.addParameters("--abort"); GitTask task = new GitTask(myProject, rh, "Aborting rebase"); + task.setProgressIndicator(myProgressIndicator); task.executeAsync(new GitTaskResultNotificationHandler(myProject, "Rebase aborted", "Abort rebase cancelled", "Error aborting rebase")); } @@ -85,6 +90,7 @@ public class GitRebaser { final GitTask rebaseTask = new GitTask(myProject, rh, "git rebase " + startOperation); rebaseTask.setProgressAnalyzer(new GitStandardProgressAnalyzer()); + rebaseTask.setProgressIndicator(myProgressIndicator); return executeRebaseTaskInBackground(root, rh, rebaseConflictDetector, rebaseTask); } @@ -130,6 +136,7 @@ public class GitRebaser { rebaseEditorService.configureHandler(h, rebaseEditorNo); final GitTask rebaseTask = new GitTask(myProject, h, "Reordering commits"); + rebaseTask.setProgressIndicator(myProgressIndicator); return executeRebaseTaskInBackground(root, h, rebaseConflictDetector, rebaseTask); } finally { // unregistering rebase service diff --git a/plugins/git4idea/src/git4idea/update/GitRebaseUpdater.java b/plugins/git4idea/src/git4idea/update/GitRebaseUpdater.java index eae8f961c549..e346cb228d25 100644 --- a/plugins/git4idea/src/git4idea/update/GitRebaseUpdater.java +++ b/plugins/git4idea/src/git4idea/update/GitRebaseUpdater.java @@ -47,7 +47,7 @@ public class GitRebaseUpdater extends GitUpdater { ProgressIndicator progressIndicator, UpdatedFiles updatedFiles) { super(project, root, gitUpdateProcess, progressIndicator, updatedFiles); - myRebaser = new GitRebaser(myProject); + myRebaser = new GitRebaser(myProject, myProgressIndicator); } @Override public boolean isSaveNeeded() { diff --git a/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java b/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java index ab4dba37129d..5cf3b2e500aa 100644 --- a/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java +++ b/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java @@ -311,7 +311,7 @@ public class GitUpdateProcess { * @return true if rebase is in progress, which means that update can't continue. */ private boolean checkRebaseInProgress() { - final GitRebaser rebaser = new GitRebaser(myProject); + final GitRebaser rebaser = new GitRebaser(myProject, myProgressIndicator); final Collection rebasingRoots = rebaser.getRebasingRoots(); if (rebasingRoots.isEmpty()) { return false; diff --git a/plugins/git4idea/tests/git4idea/tests/rebase/GitRebaserReorderCommitsTest.java b/plugins/git4idea/tests/git4idea/tests/rebase/GitRebaserReorderCommitsTest.java index 9f4ffc9820ad..80844463c18a 100644 --- a/plugins/git4idea/tests/git4idea/tests/rebase/GitRebaserReorderCommitsTest.java +++ b/plugins/git4idea/tests/git4idea/tests/rebase/GitRebaserReorderCommitsTest.java @@ -40,7 +40,7 @@ public class GitRebaserReorderCommitsTest extends GitSingleUserTest { @BeforeMethod @Override protected void setUp() throws Exception { super.setUp(); - myRebaser = new GitRebaser(myProject); + myRebaser = new GitRebaser(myProject, null); myRoot = myRepo.getDir(); myFirstCommit = makeCommit(); }