diff options
author | Andrey Loskutov | 2019-05-25 07:58:30 +0000 |
---|---|---|
committer | Andrey Loskutov | 2019-05-25 18:38:38 +0000 |
commit | 20888fc08c6e4c50fe86e9f4bfa95694cfba4ce6 (patch) | |
tree | b5aee3a911bb669c6df035d617e9a820c2050fb6 /org.eclipse.egit.ui/src/org/eclipse/egit/ui | |
parent | f8a4f483852b331c90600b1c7c96c43ac9b1c682 (diff) | |
download | egit-20888fc08c6e4c50fe86e9f4bfa95694cfba4ce6.tar.gz egit-20888fc08c6e4c50fe86e9f4bfa95694cfba4ce6.tar.xz egit-20888fc08c6e4c50fe86e9f4bfa95694cfba4ce6.zip |
Commit editor and info builder: use progress callback for RevWalkUtils
Use progress monitor version of
RevWalkUtils.findBranchesReachableFrom(). This is required to allow user
cancel long running operations and see progress.
Bug: 547642
Change-Id: Ie34937397e2552a505fd9b6db2834f1dc6d2af0d
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Diffstat (limited to 'org.eclipse.egit.ui/src/org/eclipse/egit/ui')
3 files changed, 27 insertions, 8 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/JobFamilies.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/JobFamilies.java index 2fe4a283a3..33befcaa24 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/JobFamilies.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/JobFamilies.java @@ -124,6 +124,11 @@ public class JobFamilies { public final static Object FORMAT_COMMIT_INFO = new JobFamily(); /** + * Commit editor job + */ + public final static Object COMMIT_EDITOR = new JobFamily(); + + /** * Fill tag list */ public final static Object FILL_TAG_LIST = new JobFamily(UIIcons.TAGS); diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditorPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditorPage.java index 7497d3c6dc..532106ef15 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditorPage.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitEditorPage.java @@ -23,14 +23,18 @@ import java.util.List; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.PlatformObject; import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.egit.core.AdapterUtils; +import org.eclipse.egit.core.EclipseGitProgressTransformer; import org.eclipse.egit.core.internal.Utils; import org.eclipse.egit.ui.Activator; +import org.eclipse.egit.ui.JobFamilies; import org.eclipse.egit.ui.UIPreferences; import org.eclipse.egit.ui.UIUtils; import org.eclipse.egit.ui.internal.ClipboardUtils; @@ -634,13 +638,14 @@ public class CommitEditorPage extends FormPage return Collections.emptyList(); } if (refs.size() < BRANCH_LIMIT_FOR_SYNC_LOAD) { - return findBranchesReachableFromCommit(commit, refs); + return findBranchesReachableFromCommit(commit, refs, + new NullProgressMonitor()); } else { Job branchRefreshJob = new CommitEditorPageJob(commit) { @Override protected IStatus run(IProgressMonitor monitor) { List<Ref> branches = findBranchesReachableFromCommit(commit, - refs); + refs, monitor); updateUI(monitor, () -> fillBranches(branches)); return Status.OK_STATUS; } @@ -651,10 +656,12 @@ public class CommitEditorPage extends FormPage } private List<Ref> findBranchesReachableFromCommit(RepositoryCommit commit, - List<Ref> refs) { + List<Ref> refs, IProgressMonitor monitor) { + EclipseGitProgressTransformer progress = new EclipseGitProgressTransformer( + SubMonitor.convert(monitor, refs.size())); try (RevWalk revWalk = new RevWalk(commit.getRepository())) { return RevWalkUtils.findBranchesReachableFrom(commit.getRevCommit(), - revWalk, refs); + revWalk, refs, progress); } catch (IOException e) { Activator.handleError(e.getMessage(), e, false); return Collections.emptyList(); @@ -713,7 +720,8 @@ public class CommitEditorPage extends FormPage @Override public boolean belongsTo(Object family) { - return CommitEditorPage.this == family; + return CommitEditorPage.this == family + || JobFamilies.COMMIT_EDITOR == family; } protected final void updateUI(IProgressMonitor monitor, Runnable task) { diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitInfoBuilder.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitInfoBuilder.java index 56a6c9b06d..bae4881567 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitInfoBuilder.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitInfoBuilder.java @@ -25,6 +25,8 @@ import java.util.List; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.SubMonitor; +import org.eclipse.egit.core.EclipseGitProgressTransformer; import org.eclipse.egit.ui.Activator; import org.eclipse.egit.ui.UIPreferences; import org.eclipse.egit.ui.internal.CommonUtils; @@ -120,7 +122,7 @@ public class CommitInfoBuilder { if(Activator.getDefault().getPreferenceStore().getBoolean( UIPreferences.HISTORY_SHOW_BRANCH_SEQUENCE)) { try (RevWalk rw = new RevWalk(db)) { - List<Ref> branches = getBranches(commit, allRefs, db); + List<Ref> branches = getBranches(commit, allRefs, db, monitor); Collections.sort(branches, CommonUtils.REF_ASCENDING_COMPARATOR); if (!branches.isEmpty()) { @@ -255,18 +257,22 @@ public class CommitInfoBuilder { * @param commit * @param allRefs * @param db + * @param monitor * @return List of heads from those current commit is reachable * @throws MissingObjectException * @throws IncorrectObjectTypeException * @throws IOException */ private static List<Ref> getBranches(RevCommit commit, - Collection<Ref> allRefs, Repository db) + Collection<Ref> allRefs, Repository db, IProgressMonitor monitor) throws MissingObjectException, IncorrectObjectTypeException, IOException { + EclipseGitProgressTransformer progress = new EclipseGitProgressTransformer( + SubMonitor.convert(monitor, allRefs.size())); try (RevWalk revWalk = new RevWalk(db)) { revWalk.setRetainBody(false); - return RevWalkUtils.findBranchesReachableFrom(commit, revWalk, allRefs); + return RevWalkUtils.findBranchesReachableFrom(commit, revWalk, + allRefs, progress); } } |