コード例 #1
0
  @NotNull
  private DiffInfo doLoadDiffInfo(@NotNull final BranchInfo branch) throws VcsException {
    // TODO: make cancelable and abort old speculative requests (when git4idea will allow to do so)
    String currentBranch = myCurrentBranch;
    String targetBranch = branch.getForkInfo().getRemoteName() + "/" + branch.getRemoteName();

    List<GitCommit> commits1 =
        GitHistoryUtils.history(myProject, myGitRepository.getRoot(), ".." + targetBranch);
    List<GitCommit> commits2 =
        GitHistoryUtils.history(myProject, myGitRepository.getRoot(), targetBranch + "..");
    Collection<Change> diff =
        GitChangeUtils.getDiff(
            myProject, myGitRepository.getRoot(), targetBranch, myCurrentBranch, null);
    GitCommitCompareInfo info =
        new GitCommitCompareInfo(GitCommitCompareInfo.InfoType.BRANCH_TO_HEAD);
    info.put(myGitRepository, diff);
    info.put(myGitRepository, Couple.of(commits1, commits2));

    return new DiffInfo(info, currentBranch, targetBranch);
  }
 @Nullable
 private static DiffInfo loadDiffInfo(
     @NotNull final Project project,
     @NotNull final GitRepository repository,
     @NotNull final String currentBranch,
     @NotNull final String targetBranch) {
   try {
     List<GitCommit> commits1 =
         GitHistoryUtils.history(project, repository.getRoot(), ".." + targetBranch);
     List<GitCommit> commits2 =
         GitHistoryUtils.history(project, repository.getRoot(), targetBranch + "..");
     Collection<Change> diff =
         GitChangeUtils.getDiff(
             repository.getProject(), repository.getRoot(), targetBranch, currentBranch, null);
     GitCommitCompareInfo info =
         new GitCommitCompareInfo(GitCommitCompareInfo.InfoType.BRANCH_TO_HEAD);
     info.put(repository, diff);
     info.put(repository, Pair.create(commits1, commits2));
     return new DiffInfo(info, currentBranch, targetBranch);
   } catch (VcsException e) {
     LOG.info(e);
     return null;
   }
 }