Search in sources :

Example 1 with ReachableNodes

use of com.intellij.vcs.log.graph.impl.facade.ReachableNodes 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 ReachableNodes

use of com.intellij.vcs.log.graph.impl.facade.ReachableNodes in project intellij-community by JetBrains.

the class FileHistoryFilterer method findAncestorRowAffectingFile.

private int findAncestorRowAffectingFile(@NotNull PermanentGraphImpl<Integer> permanentGraph, @NotNull Hash hash, @NotNull VisibleGraph<Integer> visibleGraph, @NotNull IndexDataGetter.FileNamesData fileNamesData) {
    Ref<Integer> result = new Ref<>();
    PermanentCommitsInfoImpl<Integer> commitsInfo = permanentGraph.getPermanentCommitsInfo();
    ReachableNodes reachableNodes = new ReachableNodes(LinearGraphUtils.asLiteLinearGraph(permanentGraph.getLinearGraph()));
    reachableNodes.walk(Collections.singleton(commitsInfo.getNodeId(myStorage.getCommitIndex(hash, myRoot))), true, currentNode -> {
        int id = commitsInfo.getCommitId(currentNode);
        if (fileNamesData.affects(id, myFilePath)) {
            result.set(currentNode);
            return false;
        }
        return true;
    });
    if (!result.isNull()) {
        Integer rowIndex = visibleGraph.getVisibleRowIndex(commitsInfo.getCommitId(result.get()));
        return ObjectUtils.assertNotNull(rowIndex);
    }
    return -1;
}
Also used : VcsRef(com.intellij.vcs.log.VcsRef) Ref(com.intellij.openapi.util.Ref) ReachableNodes(com.intellij.vcs.log.graph.impl.facade.ReachableNodes)

Aggregations

ReachableNodes (com.intellij.vcs.log.graph.impl.facade.ReachableNodes)2 Ref (com.intellij.openapi.util.Ref)1 VcsRef (com.intellij.vcs.log.VcsRef)1 GraphCommit (com.intellij.vcs.log.graph.GraphCommit)1 LinearGraph (com.intellij.vcs.log.graph.api.LinearGraph)1