use of com.intellij.vcs.log.VcsLogProvider in project intellij-community by JetBrains.
the class VcsLogManager method findLogProviders.
@NotNull
public static Map<VirtualFile, VcsLogProvider> findLogProviders(@NotNull Collection<VcsRoot> roots, @NotNull Project project) {
Map<VirtualFile, VcsLogProvider> logProviders = ContainerUtil.newHashMap();
VcsLogProvider[] allLogProviders = Extensions.getExtensions(VcsLogProvider.LOG_PROVIDER_EP, project);
for (VcsRoot root : roots) {
AbstractVcs vcs = root.getVcs();
VirtualFile path = root.getPath();
if (vcs == null || path == null) {
LOG.error("Skipping invalid VCS root: " + root);
continue;
}
for (VcsLogProvider provider : allLogProviders) {
if (provider.getSupportedVcs().equals(vcs.getKeyInstanceMethod())) {
logProviders.put(path, provider);
break;
}
}
}
return logProviders;
}
use of com.intellij.vcs.log.VcsLogProvider in project intellij-community by JetBrains.
the class AbstractDataGetter method preLoadCommitData.
@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 = myStorage.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 = myStorage.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;
}
use of com.intellij.vcs.log.VcsLogProvider in project intellij-community by JetBrains.
the class VcsGoToRefComparator method compare.
@Override
public int compare(@NotNull VcsRef ref1, @NotNull VcsRef ref2) {
VcsLogProvider provider1 = myProviders.get(ref1.getRoot());
VcsLogProvider provider2 = myProviders.get(ref2.getRoot());
if (provider1 == null)
return provider2 == null ? ref1.getName().compareTo(ref2.getName()) : 1;
if (provider2 == null)
return -1;
if (provider1 == provider2) {
return provider1.getReferenceManager().getLabelsOrderComparator().compare(ref1, ref2);
}
return provider1.getSupportedVcs().getName().compareTo(provider2.getSupportedVcs().getName());
}
use of com.intellij.vcs.log.VcsLogProvider in project intellij-community by JetBrains.
the class VcsLogRepoSizeCollector method groupRootsByVcs.
@NotNull
private static MultiMap<VcsKey, VirtualFile> groupRootsByVcs(@NotNull Map<VirtualFile, VcsLogProvider> providers) {
MultiMap<VcsKey, VirtualFile> result = MultiMap.create();
for (Map.Entry<VirtualFile, VcsLogProvider> entry : providers.entrySet()) {
VirtualFile root = entry.getKey();
VcsKey vcs = entry.getValue().getSupportedVcs();
result.putValue(vcs, root);
}
return result;
}
use of com.intellij.vcs.log.VcsLogProvider in project intellij-community by JetBrains.
the class SnapshotVisiblePackBuilder method createRefsModel.
private RefsModel createRefsModel(@NotNull RefsModel refsModel, @NotNull Set<Integer> heads, @NotNull VisibleGraph<Integer> visibleGraph, @NotNull Map<VirtualFile, VcsLogProvider> providers) {
Set<VcsRef> branchesAndHeads = ContainerUtil.newHashSet();
refsModel.getBranches().stream().filter(ref -> {
int index = myStorage.getCommitIndex(ref.getCommitHash(), ref.getRoot());
Integer row = visibleGraph.getVisibleRowIndex(index);
return row != null && row >= 0;
}).forEach(branchesAndHeads::add);
heads.stream().flatMap(head -> refsModel.refsToCommit(head).stream()).forEach(branchesAndHeads::add);
Map<VirtualFile, Set<VcsRef>> map = VcsLogUtil.groupRefsByRoot(branchesAndHeads);
Map<VirtualFile, CompressedRefs> refs = ContainerUtil.newHashMap();
for (VirtualFile root : providers.keySet()) {
Set<VcsRef> refsForRoot = map.get(root);
refs.put(root, new CompressedRefs(refsForRoot == null ? ContainerUtil.newHashSet() : refsForRoot, myStorage));
}
return new RefsModel(refs, heads, myStorage, providers);
}
Aggregations