Search in sources :

Example 1 with LinearGraph

use of com.intellij.vcs.log.graph.api.LinearGraph in project intellij-community by JetBrains.

the class ContainingBranchesTest method runTest.

@Override
protected void runTest(String in, String out) {
    int i = in.indexOf(SEPARATOR);
    List<GraphCommit<CommitId>> commits = getCommitIdManager().parseCommitList(in.substring(0, i));
    LinearGraph graph = PermanentLinearGraphBuilder.newInstance(commits).build();
    Set<Integer> branches = parseBranchNodeIndex(in.substring(i + SEPARATOR.length()));
    ReachableNodes reachableNodes = new ReachableNodes(LinearGraphUtils.asLiteLinearGraph(graph));
    assertEquals(out, containingBranchesGetterToStr(reachableNodes, branches, graph.nodesCount()));
}
Also used : ReachableNodes(com.intellij.vcs.log.graph.impl.facade.ReachableNodes) GraphCommit(com.intellij.vcs.log.graph.GraphCommit) LinearGraph(com.intellij.vcs.log.graph.api.LinearGraph)

Example 2 with LinearGraph

use of com.intellij.vcs.log.graph.api.LinearGraph in project intellij-community by JetBrains.

the class CollapsedController method delegateGraphChanged.

@NotNull
@Override
protected LinearGraphAnswer delegateGraphChanged(@NotNull LinearGraphAnswer delegateAnswer) {
    if (delegateAnswer.getGraphChanges() != null) {
        LinearGraph delegateGraph = getDelegateController().getCompiledGraph();
        myCollapsedGraph = CollapsedGraph.updateInstance(myCollapsedGraph, delegateGraph);
        // some new edges and node appeared, so we expand them
        applyDelegateChanges(delegateGraph, delegateAnswer.getGraphChanges());
    }
    // if somebody outside actually uses changes we return here they are screwed
    return delegateAnswer;
}
Also used : LinearGraph(com.intellij.vcs.log.graph.api.LinearGraph) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with LinearGraph

use of com.intellij.vcs.log.graph.api.LinearGraph in project intellij-community by JetBrains.

the class SimpleGraphInfo method build.

public static <CommitId> SimpleGraphInfo<CommitId> build(@NotNull LinearGraph linearGraph, @NotNull GraphLayout oldLayout, @NotNull PermanentCommitsInfo<CommitId> permanentCommitsInfo, int permanentGraphSize, @NotNull Set<Integer> branchNodeIds) {
    // todo get first visible row from table somehow
    int firstVisibleRow = VISIBLE_RANGE;
    int start = Math.max(0, firstVisibleRow - VISIBLE_RANGE);
    // no more than 2*1000 commits;
    int end = Math.min(linearGraph.nodesCount(), start + 2 * VISIBLE_RANGE);
    List<GraphCommit<CommitId>> graphCommits = ContainerUtil.newArrayListWithCapacity(end - start);
    List<CommitId> commitsIdMap = ContainerUtil.newArrayListWithCapacity(end - start);
    for (int row = start; row < end; row++) {
        int nodeId = linearGraph.getNodeId(row);
        CommitId commit = permanentCommitsInfo.getCommitId(nodeId);
        List<CommitId> parents = ContainerUtil.newSmartList();
        parents.addAll(ContainerUtil.mapNotNull(asLiteLinearGraph(linearGraph).getNodes(row, LiteLinearGraph.NodeFilter.DOWN), row1 -> {
            if (row1 < start || row1 >= end)
                return null;
            return permanentCommitsInfo.getCommitId(linearGraph.getNodeId(row1));
        }));
        graphCommits.add(GraphCommitImpl.createCommit(commit, parents, permanentCommitsInfo.getTimestamp(nodeId)));
        commitsIdMap.add(commit);
    }
    IntTimestampGetter timestampGetter = PermanentCommitsInfoImpl.createTimestampGetter(graphCommits);
    NotNullFunction<Integer, CommitId> function = createCommitIdMapFunction(commitsIdMap);
    PermanentLinearGraphImpl newLinearGraph = PermanentLinearGraphBuilder.newInstance(graphCommits).build();
    int[] layoutIndexes = new int[end - start];
    List<Integer> headNodeIndexes = ContainerUtil.newArrayList();
    TObjectIntHashMap<CommitId> commitIdToInteger = reverseCommitIdMap(permanentCommitsInfo, permanentGraphSize);
    for (int row = start; row < end; row++) {
        CommitId commitId = commitsIdMap.get(row - start);
        int layoutIndex = oldLayout.getLayoutIndex(commitIdToInteger.get(commitId));
        layoutIndexes[row - start] = layoutIndex;
        if (asLiteLinearGraph(newLinearGraph).getNodes(row - start, LiteLinearGraph.NodeFilter.UP).isEmpty()) {
            headNodeIndexes.add(row - start);
        }
    }
    ContainerUtil.sort(headNodeIndexes, Comparator.comparingInt(o -> layoutIndexes[o]));
    int[] starts = new int[headNodeIndexes.size()];
    for (int i = 0; i < starts.length; i++) {
        starts[i] = layoutIndexes[headNodeIndexes.get(i)];
    }
    GraphLayoutImpl newLayout = new GraphLayoutImpl(layoutIndexes, headNodeIndexes, starts);
    return new SimpleGraphInfo<>(newLinearGraph, newLayout, function, timestampGetter, LinearGraphUtils.convertIdsToNodeIndexes(linearGraph, branchNodeIds));
}
Also used : GraphCommitImpl(com.intellij.vcs.log.graph.GraphCommitImpl) TObjectIntHashMap(gnu.trove.TObjectIntHashMap) TimestampGetter(com.intellij.vcs.log.graph.utils.TimestampGetter) CompressedIntList(com.intellij.vcs.log.graph.utils.impl.CompressedIntList) ContainerUtil(com.intellij.util.containers.ContainerUtil) IntList(com.intellij.vcs.log.graph.utils.IntList) LiteLinearGraph(com.intellij.vcs.log.graph.api.LiteLinearGraph) LinearGraph(com.intellij.vcs.log.graph.api.LinearGraph) PermanentLinearGraphImpl(com.intellij.vcs.log.graph.impl.permanent.PermanentLinearGraphImpl) LinearGraphUtils(com.intellij.vcs.log.graph.utils.LinearGraphUtils) GraphCommit(com.intellij.vcs.log.graph.GraphCommit) GraphLayoutImpl(com.intellij.vcs.log.graph.impl.permanent.GraphLayoutImpl) NotNullFunction(com.intellij.util.NotNullFunction) Collection(java.util.Collection) Set(java.util.Set) PermanentCommitsInfo(com.intellij.vcs.log.graph.api.permanent.PermanentCommitsInfo) PermanentCommitsInfoImpl(com.intellij.vcs.log.graph.impl.permanent.PermanentCommitsInfoImpl) GraphLayout(com.intellij.vcs.log.graph.api.GraphLayout) List(java.util.List) PermanentLinearGraphBuilder(com.intellij.vcs.log.graph.impl.permanent.PermanentLinearGraphBuilder) PermanentGraphInfo(com.intellij.vcs.log.graph.api.permanent.PermanentGraphInfo) NotNull(org.jetbrains.annotations.NotNull) Comparator(java.util.Comparator) IntTimestampGetter(com.intellij.vcs.log.graph.utils.impl.IntTimestampGetter) LinearGraphUtils.asLiteLinearGraph(com.intellij.vcs.log.graph.utils.LinearGraphUtils.asLiteLinearGraph) PermanentLinearGraphImpl(com.intellij.vcs.log.graph.impl.permanent.PermanentLinearGraphImpl) IntTimestampGetter(com.intellij.vcs.log.graph.utils.impl.IntTimestampGetter) GraphLayoutImpl(com.intellij.vcs.log.graph.impl.permanent.GraphLayoutImpl) GraphCommit(com.intellij.vcs.log.graph.GraphCommit)

Example 4 with LinearGraph

use of com.intellij.vcs.log.graph.api.LinearGraph in project intellij-community by JetBrains.

the class EdgesInRowTest method runTest.

@Override
protected void runTest(String in, String out) {
    LinearGraph graph = LinearGraphParser.parse(in);
    EdgesInRowGenerator edgesInRowGenerator = new EdgesInRowGenerator(graph);
    assertEquals(out, edgesInRowToStr(edgesInRowGenerator, graph.nodesCount()));
}
Also used : LinearGraph(com.intellij.vcs.log.graph.api.LinearGraph)

Aggregations

LinearGraph (com.intellij.vcs.log.graph.api.LinearGraph)4 GraphCommit (com.intellij.vcs.log.graph.GraphCommit)2 NotNull (org.jetbrains.annotations.NotNull)2 NotNullFunction (com.intellij.util.NotNullFunction)1 ContainerUtil (com.intellij.util.containers.ContainerUtil)1 GraphCommitImpl (com.intellij.vcs.log.graph.GraphCommitImpl)1 GraphLayout (com.intellij.vcs.log.graph.api.GraphLayout)1 LiteLinearGraph (com.intellij.vcs.log.graph.api.LiteLinearGraph)1 PermanentCommitsInfo (com.intellij.vcs.log.graph.api.permanent.PermanentCommitsInfo)1 PermanentGraphInfo (com.intellij.vcs.log.graph.api.permanent.PermanentGraphInfo)1 ReachableNodes (com.intellij.vcs.log.graph.impl.facade.ReachableNodes)1 GraphLayoutImpl (com.intellij.vcs.log.graph.impl.permanent.GraphLayoutImpl)1 PermanentCommitsInfoImpl (com.intellij.vcs.log.graph.impl.permanent.PermanentCommitsInfoImpl)1 PermanentLinearGraphBuilder (com.intellij.vcs.log.graph.impl.permanent.PermanentLinearGraphBuilder)1 PermanentLinearGraphImpl (com.intellij.vcs.log.graph.impl.permanent.PermanentLinearGraphImpl)1 IntList (com.intellij.vcs.log.graph.utils.IntList)1 LinearGraphUtils (com.intellij.vcs.log.graph.utils.LinearGraphUtils)1 LinearGraphUtils.asLiteLinearGraph (com.intellij.vcs.log.graph.utils.LinearGraphUtils.asLiteLinearGraph)1 TimestampGetter (com.intellij.vcs.log.graph.utils.TimestampGetter)1 CompressedIntList (com.intellij.vcs.log.graph.utils.impl.CompressedIntList)1