matthiasblaesing commented on code in PR #9305:
URL: https://github.com/apache/netbeans/pull/9305#discussion_r3213709384
##########
ide/git/src/org/netbeans/modules/git/ui/repository/RepositoryBrowserPanel.java:
##########
@@ -339,6 +341,38 @@ private File lookupRepository (Node selectedNode) {
return selectedNode == null ? null : ((RepositoryNode)
selectedNode).getRepository();
}
+ private void computeMergeStatusForSelectedNodeIfNotComputedYet () {
+ if (branchMergeWith == null ||
getExplorerManager().getSelectedNodes().length != 1) {
+ return;
+ }
+ Node selectedNode = getExplorerManager().getSelectedNodes()[0];
+ if (!(selectedNode instanceof BranchNode)) {
+ return;
+ }
+ final BranchNode branchNode = (BranchNode) selectedNode;
+ if (branchNode.mergeStatus != null) {
+ return;
+ }
+ final String mergeWith = branchMergeWith;
+ final String branchName = branchNode.branchName;
+ // Walk up to BranchesTopChildren via parent chain
+ Node parent = branchNode.getParentNode();
+ if (parent != null) {
+ parent = parent.getParentNode();
+ }
Review Comment:
Shouldn't this be a loop? Else you only go one level up.
##########
ide/git/src/org/netbeans/modules/git/ui/repository/RepositoryBrowserPanel.java:
##########
@@ -924,6 +943,64 @@ && equalTracking(newBranchInfo, e.getValue().branch))) {
if (remote != null) {
remote.refresh();
}
+ // Compute merge status in a separate task so node population is
not blocked.
+ if (branchMergeWith != null) {
+ final String mergeWith = branchMergeWith;
+ final java.util.Map<String, String> snapshot = new
HashMap<String, String>();
+ for (java.util.Map.Entry<String, GitBranchInfo> e :
BranchesTopChildren.this.branches.entrySet()) {
+ snapshot.put(e.getKey(), e.getValue().branch.getId());
+ }
+ RP.post(() -> computeMergeStatuses(snapshot, mergeWith));
+ }
+ }
+
+ private void computeMergeStatuses (java.util.Map<String, String>
snapshot, String mergeWith) {
+ GitClient client = null;
+ try {
+ client = Git.getInstance().getClient(repository);
+ for (java.util.Map.Entry<String, String> e :
snapshot.entrySet()) {
+ GitRevisionInfo commonAncestor = client.getCommonAncestor(
+ new String[] { mergeWith, e.getValue() },
+ GitUtils.NULL_PROGRESS_MONITOR);
+ boolean merged = commonAncestor != null
+ &&
commonAncestor.getRevision().equals(e.getValue());
+ updateBranchMergeStatus(e.getKey(), merged);
+ }
+ } catch (GitException ex) {
+ LOG.log(Level.INFO, null, ex);
+ } finally {
+ if (client != null) {
+ client.release();
+ }
+ }
+ }
+
+ void computeSingleMergeStatus (String branchName, String mergeWith) {
+ GitBranchInfo info =
BranchesTopChildren.this.branches.get(branchName);
+ if (info == null) {
+ return;
+ }
+ java.util.Map<String, String> single = new HashMap<String,
String>();
+ single.put(branchName, info.branch.getId());
Review Comment:
Use `Map#of`?
##########
ide/git/src/org/netbeans/modules/git/ui/repository/RepositoryBrowserPanel.java:
##########
@@ -307,13 +307,15 @@ public void propertyChange (PropertyChangeEvent evt) {
currRevision = selectedNode.getLookup().lookup(Revision.class);
currRepository = lookupRepository(selectedNode);
}
- if ((currRevision != null || oldRevision != null) &&
!(currRevision != null && oldRevision != null
+ if ((currRevision != null || oldRevision != null) &&
!(currRevision != null && oldRevision != null
&& currRevision.equals(oldRevision))) {
firePropertyChange(PROP_REVISION_CHANGED, oldRevision,
currRevision);
}
if (options.contains(Option.DISPLAY_REVISIONS) && currRevision !=
null) {
revisionsPanel1.updateHistory(currRepository, roots,
currRevision);
}
+ // If a branch node with pending merge status is selected, compute
it immediately.
+ computeMergeStatusForSelectedNodeIfNotComputedYet();
Review Comment:
This does not work for me. If I see it correctly in may case (git checkout
of netbeans with all PR branches) the `RequestProcessor` `RP` has a throughput
of 1 and that one place is blocked by the initial merge status determination
(`computeMergeStatuses`).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists