コード例 #1
0
  @NotNull
  public TIntObjectHashMap<T> preLoadCommitData(@NotNull TIntHashSet commits) throws VcsException {
    TIntObjectHashMap<T> result = new TIntObjectHashMap<>();
    final MultiMap<VirtualFile, String> rootsAndHashes = MultiMap.create();
    commits.forEach(
        commit -> {
          CommitId commitId = myHashMap.getCommitId(commit);
          if (commitId != null) {
            rootsAndHashes.putValue(commitId.getRoot(), commitId.getHash().asString());
          }
          return true;
        });

    for (Map.Entry<VirtualFile, Collection<String>> entry : rootsAndHashes.entrySet()) {
      VcsLogProvider logProvider = myLogProviders.get(entry.getKey());
      if (logProvider != null) {
        List<? extends T> details =
            readDetails(logProvider, entry.getKey(), ContainerUtil.newArrayList(entry.getValue()));
        for (T data : details) {
          int index = myHashMap.getCommitIndex(data.getId(), data.getRoot());
          result.put(index, data);
        }
        saveInCache(result);
      } else {
        LOG.error(
            "No log provider for root "
                + entry.getKey().getPath()
                + ". All known log providers "
                + myLogProviders);
      }
    }

    return result;
  }
コード例 #2
0
 private void sortCommitsByRow(
     @NotNull List<T> result, @NotNull final TIntIntHashMap rowsForCommits) {
   ContainerUtil.sort(
       result,
       (details1, details2) -> {
         int row1 =
             rowsForCommits.get(myHashMap.getCommitIndex(details1.getId(), details1.getRoot()));
         int row2 =
             rowsForCommits.get(myHashMap.getCommitIndex(details2.getId(), details2.getRoot()));
         return Comparing.compare(row1, row2);
       });
 }
コード例 #3
0
  public RefsModel(
      @NotNull Map<VirtualFile, CompressedRefs> refs,
      @NotNull Set<Integer> heads,
      @NotNull VcsLogStorage hashMap,
      @NotNull Map<VirtualFile, VcsLogProvider> providers) {
    myRefs = refs;
    myHashMap = hashMap;

    myBestRefForHead = new TIntObjectHashMap<>();
    myRootForHead = new TIntObjectHashMap<>();
    for (int head : heads) {
      CommitId commitId = myHashMap.getCommitId(head);
      if (commitId != null) {
        VirtualFile root = commitId.getRoot();
        myRootForHead.put(head, root);
        Optional<VcsRef> bestRef =
            myRefs
                .get(root)
                .refsToCommit(head)
                .stream()
                .min(providers.get(root).getReferenceManager().getBranchLayoutComparator());
        if (bestRef.isPresent()) {
          myBestRefForHead.put(head, bestRef.get());
        } else {
          LOG.warn("No references at head " + commitId);
        }
      }
    }
  }
コード例 #4
0
 public Collection<VcsRef> refsToCommit(int index) {
   CommitId id = myHashMap.getCommitId(index);
   if (id == null) return Collections.emptyList();
   VirtualFile root = id.getRoot();
   return myRefs.get(root).refsToCommit(index);
 }