use of com.intellij.vcs.log.graph.GraphCommit 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()));
}
use of com.intellij.vcs.log.graph.GraphCommit in project intellij-community by JetBrains.
the class VcsLogRefresherImpl method compactCommits.
@NotNull
private List<GraphCommit<Integer>> compactCommits(@NotNull List<? extends TimedVcsCommit> commits, @NotNull final VirtualFile root) {
StopWatch sw = StopWatch.start("compacting commits");
List<GraphCommit<Integer>> map = ContainerUtil.map(commits, new Function<TimedVcsCommit, GraphCommit<Integer>>() {
@NotNull
@Override
public GraphCommit<Integer> fun(@NotNull TimedVcsCommit commit) {
return compactCommit(commit, root);
}
});
myStorage.flush();
sw.report();
return map;
}
use of com.intellij.vcs.log.graph.GraphCommit 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));
}
use of com.intellij.vcs.log.graph.GraphCommit in project intellij-community by JetBrains.
the class GraphLayoutBuilderTest method runTest.
@Override
protected void runTest(String in, String out) {
final CommitIdManager<CommitId> idManager = getCommitIdManager();
final List<GraphCommit<CommitId>> commits = idManager.parseCommitList(in);
PermanentLinearGraphBuilder<CommitId> graphBuilder = PermanentLinearGraphBuilder.newInstance(commits);
PermanentLinearGraphImpl graph = graphBuilder.build();
GraphLayout graphLayout = GraphLayoutBuilder.build(graph, new Comparator<Integer>() {
@Override
public int compare(@NotNull Integer o1, @NotNull Integer o2) {
CommitId id1 = commits.get(o1).getId();
CommitId id2 = commits.get(o2).getId();
return idManager.toStr(id1).compareTo(idManager.toStr(id2));
}
});
assertEquals(out, permanentGraphLayoutModelToStr(graphLayout, graph.nodesCount()));
}
use of com.intellij.vcs.log.graph.GraphCommit in project intellij-community by JetBrains.
the class PermanentCommitsInfoImpl method newInstance.
@NotNull
public static <CommitId> PermanentCommitsInfoImpl<CommitId> newInstance(@NotNull final List<? extends GraphCommit<CommitId>> graphCommits, @NotNull Map<Integer, CommitId> notLoadedCommits) {
TimestampGetter timestampGetter = createTimestampGetter(graphCommits);
boolean isIntegerCase = !graphCommits.isEmpty() && graphCommits.get(0).getId().getClass() == Integer.class;
List<CommitId> commitIdIndex;
if (isIntegerCase) {
commitIdIndex = (List<CommitId>) createCompressedIntList((List<? extends GraphCommit<Integer>>) graphCommits);
} else {
commitIdIndex = ContainerUtil.map(graphCommits, (Function<GraphCommit<CommitId>, CommitId>) GraphCommit::getId);
}
return new PermanentCommitsInfoImpl<>(timestampGetter, commitIdIndex, notLoadedCommits);
}
Aggregations