Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Keppler2019-08-13 03:56:22 -0400
committerThomas Wolf2019-08-14 12:15:10 -0400
commit37f68e0f7151b67592b592d07d4356811895ce3e (patch)
tree3f2a9ee4b53ff8585be542524790e5624979b271
parent227524b534e62af73b612c284f6066c022c2f68c (diff)
downloadegit-37f68e0f7151b67592b592d07d4356811895ce3e.tar.gz
egit-37f68e0f7151b67592b592d07d4356811895ce3e.tar.xz
egit-37f68e0f7151b67592b592d07d4356811895ce3e.zip
Fix progress reporting for some commands
Commands being executed in a loop should always use a new SubMonitor, instead of reporting multiple times against the original progress monitor. Bug: 549812 Change-Id: I8692eb45561e179618c1ed65f301662d4343b134
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/DeleteTagCommand.java10
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/GarbageCollectCommand.java10
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/StashDropCommand.java8
3 files changed, 19 insertions, 9 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/DeleteTagCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/DeleteTagCommand.java
index dee6db964..7cfa0d3bb 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/DeleteTagCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/DeleteTagCommand.java
@@ -22,6 +22,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.egit.core.op.DeleteTagOperation;
import org.eclipse.egit.ui.Activator;
@@ -71,19 +72,22 @@ public class DeleteTagCommand extends RepositoriesViewCommandHandler<TagNode> {
@Override
protected IStatus run(IProgressMonitor monitor) {
- monitor.beginTask(UIText.DeleteTagCommand_taskName, tags.size());
+ SubMonitor progress = SubMonitor.convert(monitor,
+ UIText.DeleteTagCommand_taskName, tags.size());
for (TagNode tag : tags) {
+ if (progress.isCanceled()) {
+ break;
+ }
final Repository repo = tag.getRepository();
final String tagName = tag.getObject().getName();
final DeleteTagOperation op = new DeleteTagOperation(repo,
tagName);
monitor.subTask(tagName);
try {
- op.execute(monitor);
+ op.execute(progress.newChild(1));
} catch (CoreException e) {
Activator.logError(e.getLocalizedMessage(), e);
}
- monitor.worked(1);
}
monitor.done();
return Status.OK_STATUS;
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/GarbageCollectCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/GarbageCollectCommand.java
index c8e525fb0..15fe7b2eb 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/GarbageCollectCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/GarbageCollectCommand.java
@@ -20,6 +20,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.egit.core.op.GarbageCollectOperation;
import org.eclipse.egit.ui.Activator;
@@ -62,8 +63,13 @@ public class GarbageCollectCommand extends
@Override
protected IStatus run(IProgressMonitor monitor) {
+ SubMonitor progress = SubMonitor.convert(monitor,
+ selectedNodes.size());
for (RepositoryNode node : selectedNodes) {
+ if (progress.isCanceled()) {
+ break;
+ }
Repository repo = node.getRepository();
String name = MessageFormat.format(
UIText.GarbageCollectCommand_jobTitle,
@@ -72,13 +78,13 @@ public class GarbageCollectCommand extends
final GarbageCollectOperation op = new GarbageCollectOperation(
repo);
try {
- op.execute(monitor);
+ op.execute(progress.newChild(1));
} catch (CoreException e) {
Activator.logError(MessageFormat.format(
UIText.GarbageCollectCommand_failed, repo), e);
}
}
-
+ monitor.done();
return Status.OK_STATUS;
}
};
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/StashDropCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/StashDropCommand.java
index f1456a392..e832700ee 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/StashDropCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/StashDropCommand.java
@@ -23,6 +23,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.egit.core.op.StashDropOperation;
import org.eclipse.egit.ui.Activator;
@@ -95,8 +96,8 @@ public class StashDropCommand
@Override
protected IStatus run(IProgressMonitor monitor) {
- monitor.beginTask(UIText.StashDropCommand_jobTitle,
- nodes.size());
+ SubMonitor progress = SubMonitor.convert(monitor,
+ UIText.StashDropCommand_jobTitle, nodes.size());
// Sort by highest to lowest stash commit index.
// This avoids shifting problems that cause the indices of the
@@ -116,14 +117,13 @@ public class StashDropCommand
node.getIndex());
monitor.subTask(stashName);
try {
- op.execute(monitor);
+ op.execute(progress.newChild(1));
} catch (CoreException e) {
Activator.logError(MessageFormat.format(
UIText.StashDropCommand_dropFailed,
node.getObject().name()), e);
}
tryToCloseEditor(node);
- monitor.worked(1);
}
monitor.done();
return Status.OK_STATUS;

Back to the top