Search in sources :

Example 1 with VcsLogProvider

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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsLogProvider(com.intellij.vcs.log.VcsLogProvider) VcsRoot(com.intellij.openapi.vcs.VcsRoot) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with VcsLogProvider

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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CommitId(com.intellij.vcs.log.CommitId) VcsLogProvider(com.intellij.vcs.log.VcsLogProvider) TIntObjectHashMap(gnu.trove.TIntObjectHashMap) Collection(java.util.Collection) Map(java.util.Map) TIntObjectHashMap(gnu.trove.TIntObjectHashMap) MultiMap(com.intellij.util.containers.MultiMap) TIntIntHashMap(gnu.trove.TIntIntHashMap) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with VcsLogProvider

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());
}
Also used : VcsLogProvider(com.intellij.vcs.log.VcsLogProvider)

Example 4 with VcsLogProvider

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;
}
Also used : VcsKey(com.intellij.openapi.vcs.VcsKey) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsLogProvider(com.intellij.vcs.log.VcsLogProvider) Map(java.util.Map) MultiMap(com.intellij.util.containers.MultiMap) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with VcsLogProvider

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);
}
Also used : com.intellij.vcs.log.data(com.intellij.vcs.log.data) VcsLogUtil(com.intellij.vcs.log.impl.VcsLogUtil) VirtualFile(com.intellij.openapi.vfs.VirtualFile) BaseController(com.intellij.vcs.log.graph.impl.facade.BaseController) Set(java.util.Set) VcsLogProvider(com.intellij.vcs.log.VcsLogProvider) ContainerUtil(com.intellij.util.containers.ContainerUtil) VcsRef(com.intellij.vcs.log.VcsRef) CollapsedController(com.intellij.vcs.log.graph.collapsing.CollapsedController) VcsLogFilterCollection(com.intellij.vcs.log.VcsLogFilterCollection) VisibleGraph(com.intellij.vcs.log.graph.VisibleGraph) GraphColorManagerImpl(com.intellij.vcs.log.graph.GraphColorManagerImpl) Map(java.util.Map) PermanentGraphInfo(com.intellij.vcs.log.graph.api.permanent.PermanentGraphInfo) VisibleGraphImpl(com.intellij.vcs.log.graph.impl.facade.VisibleGraphImpl) NotNull(org.jetbrains.annotations.NotNull) VirtualFile(com.intellij.openapi.vfs.VirtualFile) Set(java.util.Set) VcsRef(com.intellij.vcs.log.VcsRef)

Aggregations

VcsLogProvider (com.intellij.vcs.log.VcsLogProvider)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 NotNull (org.jetbrains.annotations.NotNull)5 Map (java.util.Map)4 MultiMap (com.intellij.util.containers.MultiMap)3 Collection (java.util.Collection)3 AbstractVcs (com.intellij.openapi.vcs.AbstractVcs)2 VcsRoot (com.intellij.openapi.vcs.VcsRoot)2 ContainerUtil (com.intellij.util.containers.ContainerUtil)2 Disposable (com.intellij.openapi.Disposable)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 StringUtil (com.intellij.openapi.util.text.StringUtil)1 VcsKey (com.intellij.openapi.vcs.VcsKey)1 CommitId (com.intellij.vcs.log.CommitId)1 VcsLogDataKeys (com.intellij.vcs.log.VcsLogDataKeys)1 VcsLogFilterCollection (com.intellij.vcs.log.VcsLogFilterCollection)1 VcsLogProperties (com.intellij.vcs.log.VcsLogProperties)1 VcsLogUi (com.intellij.vcs.log.VcsLogUi)1 VcsRef (com.intellij.vcs.log.VcsRef)1 com.intellij.vcs.log.data (com.intellij.vcs.log.data)1