mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[vcs-log-graph] compute correct start layout indexes for the branch heads
Since branch heads are now being used as the start nodes for building graph layout, a head commit might be visited earlier from another head, giving it a layout index different from the currentLayoutIndex value. This commit avoids the problem altogether by computing layout indexes array for heads after all layout indexes have been calculated. follow-up: 1cd228ff6107d0ca03d5f3172f9940e0d55d9e4f GitOrigin-RevId: c01942bad60c09979711769905ac35a43b9c98f0
This commit is contained in:
committed by
intellij-monorepo-bot
parent
00c776df24
commit
e0d855267e
+1
-6
@@ -92,12 +92,7 @@ public final class SimpleGraphInfo<CommitId> implements PermanentGraphInfo<Commi
|
||||
}
|
||||
|
||||
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.getInt(i)];
|
||||
}
|
||||
|
||||
GraphLayoutImpl newLayout = new GraphLayoutImpl(layoutIndexes, headNodeIndexes, starts);
|
||||
GraphLayoutImpl newLayout = new GraphLayoutImpl(layoutIndexes, headNodeIndexes);
|
||||
|
||||
return new SimpleGraphInfo<>(newLinearGraph, newLayout, commitIdMapping, timestampGetter,
|
||||
LinearGraphUtils.convertIdsToNodeIndexes(linearGraph, branchNodeIds));
|
||||
|
||||
+1
-3
@@ -25,13 +25,11 @@ object GraphLayoutBuilder {
|
||||
val sortedHeads = IntArrayList(allHeads).sortCatching(comparator)
|
||||
|
||||
val layoutIndex = IntArray(graph.nodesCount())
|
||||
val startLayoutIndexForHead = IntArray(sortedHeads.size)
|
||||
var currentLayoutIndex = 1
|
||||
for (i in sortedHeads.indices) {
|
||||
startLayoutIndexForHead[i] = currentLayoutIndex
|
||||
currentLayoutIndex = dfs(graph, sortedHeads.getInt(i), currentLayoutIndex, layoutIndex)
|
||||
}
|
||||
return GraphLayoutImpl(layoutIndex, sortedHeads, startLayoutIndexForHead)
|
||||
return GraphLayoutImpl(layoutIndex, sortedHeads)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+10
-3
@@ -7,9 +7,8 @@ import it.unimi.dsi.fastutil.ints.IntList
|
||||
import java.util.*
|
||||
import kotlin.math.max
|
||||
|
||||
class GraphLayoutImpl(layoutIndex: IntArray,
|
||||
private val headNodeIndex: IntList,
|
||||
private val startLayoutIndexForHead: IntArray) : GraphLayout {
|
||||
class GraphLayoutImpl(layoutIndex: IntArray, private val headNodeIndex: IntList) : GraphLayout {
|
||||
private val startLayoutIndexForHead = getLayoutIndexesForHeads(layoutIndex, headNodeIndex)
|
||||
private val layoutIndex = CompressedIntList.newInstance(layoutIndex)
|
||||
|
||||
override fun getLayoutIndex(nodeIndex: Int) = layoutIndex[nodeIndex]
|
||||
@@ -25,3 +24,11 @@ class GraphLayoutImpl(layoutIndex: IntArray,
|
||||
return if (i < 0) max(0, (-i - 2)) else i
|
||||
}
|
||||
}
|
||||
|
||||
private fun getLayoutIndexesForHeads(layoutIndexes: IntArray, headNodeIndexes: IntList): IntArray {
|
||||
val result = IntArray(headNodeIndexes.size)
|
||||
for (i in result.indices) {
|
||||
result[i] = layoutIndexes[headNodeIndexes.getInt(i)]
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user