in plugin/src/com/microsoft/alm/plugin/idea/git/ui/pullrequest/CreatePullRequestModel.java [349:429]
public void loadDiff() {
if (this.getSourceBranch() != null && this.getTargetBranch() != null) {
ListenableFuture<GitChangesContainer> diffFuture = this.executorService.submit(new Callable<GitChangesContainer>() {
@Override
public GitChangesContainer call() throws Exception {
// calculate the diffs
return getMyChangesCompareInfo();
}
});
Futures.addCallback(diffFuture, new FutureCallback<GitChangesContainer>() {
public void onSuccess(final GitChangesContainer changesContainer) {
applicationProvider.invokeAndWaitWithAnyModality(new Runnable() {
@Override
public void run() {
// try to update the view to show diff, but only if the calculated diff
// is still upto date -- make sure user didn't select another branch
// while we were busy calculating the diffs
if (changesContainer != null && isChangesUpToDate(changesContainer)) {
setLoading(false);
final GitCommitCompareInfo compareInfo = changesContainer.getGitCommitCompareInfo();
if (compareInfo != null) {
List<GitCommit> commits
= compareInfo.getBranchToHeadCommits(changesContainer.getGitRepository());
final GitLocalBranch sourceBranch = getSourceBranch();
final GitRemoteBranch targetBranch = getTargetBranch();
if (StringUtils.isEmpty(getTitle()) && commits != null && sourceBranch.getName() != null
&& targetBranch.getNameForRemoteOperations() != null) {
final String defaultTitle = pullRequestHelper.createDefaultTitle(commits,
sourceBranch.getName(),
targetBranch.getNameForRemoteOperations());
setTitle(defaultTitle);
final String defaultDescription
= pullRequestHelper.createDefaultDescription(commits);
setDescription(defaultDescription);
}
// find workitems from commits
workItems.clear();
for (final GitCommit commit : commits) {
final String commitMsg = commit.getFullMessage();
workItems.addAll(VcsHelper.getWorkItemIdsFromMessage(commitMsg));
}
}
setLocalBranchChanges(changesContainer);
}
}
});
}
public void onFailure(final Throwable thrown) {
logger.warn("onFailure in loadDiff", thrown);
applicationProvider.invokeAndWaitWithAnyModality(new Runnable() {
public void run() {
final GitLocalBranch sourceBranch = getSourceBranch();
final GitRemoteBranch targetBranch = getTargetBranch();
final String sourceBranchName = sourceBranch != null ? sourceBranch.getName() : "";
final String targetBranchName = targetBranch != null ? targetBranch.getName() : "";
notifyDiffFailedError(getProject(),
TfPluginBundle.message(TfPluginBundle.KEY_CREATE_PR_ERRORS_DIFF_FAILED_MSG,
sourceBranchName, targetBranchName));
final GitChangesContainer changesContainer = GitChangesContainer.createChangesContainer(sourceBranchName, targetBranchName, null, null,
getDiffCompareInfoProvider().getEmptyDiff(gitRepository), gitRepository);
if (isChangesUpToDate(changesContainer)) {
setLoading(false);
setLocalBranchChanges(changesContainer);
}
}
});
}
}, directExecutor());
}
}