diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/utils/GraphUtil.kt b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/utils/GraphUtil.kt index d7aa40fc1d0d..e089eea9294b 100644 --- a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/utils/GraphUtil.kt +++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/utils/GraphUtil.kt @@ -6,15 +6,15 @@ import com.intellij.vcs.log.graph.api.LinearGraph import com.intellij.vcs.log.graph.api.LiteLinearGraph import com.intellij.vcs.log.graph.utils.impl.BitSetFlags -fun getReachableNodes(graph: LinearGraph, headNodes: Set?): UnsignedBitSet { +fun LinearGraph.getReachableNodes(headNodes: Set?): UnsignedBitSet { if (headNodes == null) { val nodesVisibility = UnsignedBitSet() - nodesVisibility.set(0, graph.nodesCount() - 1, true) + nodesVisibility.set(0, nodesCount() - 1, true) return nodesVisibility } val result = UnsignedBitSet() - DfsWalk(headNodes, graph).walk(true) { node: Int -> + DfsWalk(headNodes, this).walk(true) { node: Int -> result.set(node, true) true } @@ -46,12 +46,12 @@ fun LiteLinearGraph.isAncestor(lowerNode: Int, upperNode: Int): Boolean { return result.get() } -fun getCorrespondingParent(graph: LiteLinearGraph, startNode: Int, endNode: Int, visited: Flags): Int { - val candidates = graph.getNodes(startNode, LiteLinearGraph.NodeFilter.DOWN) +fun LiteLinearGraph.getCorrespondingParent(startNode: Int, endNode: Int, visited: Flags): Int { + val candidates = getNodes(startNode, LiteLinearGraph.NodeFilter.DOWN) if (candidates.size == 1) return candidates[0] if (candidates.contains(endNode)) return endNode - val bfsWalks = candidates.mapTo(mutableListOf()) { BfsWalk(it, graph, visited) } + val bfsWalks = candidates.mapTo(mutableListOf()) { BfsWalk(it, this, visited) } visited.setAll(false) do { diff --git a/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/impl/BfsTests.kt b/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/impl/BfsTests.kt index 540dcdbe0f52..472671da66b8 100644 --- a/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/impl/BfsTests.kt +++ b/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/impl/BfsTests.kt @@ -15,8 +15,7 @@ class BfsTests { private fun assertCorrespondingParent(startNode: Int, endNode: Int, expectedParent: Int, graphBuilder: TestGraphBuilder.() -> Unit) { val graph = graph(graphBuilder) - val actualParent = getCorrespondingParent(LinearGraphUtils.asLiteLinearGraph(graph), startNode, endNode, - BitSetFlags(graph.nodesCount())) + val actualParent = LinearGraphUtils.asLiteLinearGraph(graph).getCorrespondingParent(startNode, endNode, BitSetFlags(graph.nodesCount())) assertEquals(expectedParent, actualParent, "Incorrect parent found when walking from ${startNode} to ${endNode} in ${graph.asString(true)}") } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/history/FileHistory.kt b/platform/vcs-log/impl/src/com/intellij/vcs/log/history/FileHistory.kt index a705fdab489d..4aaf3df4f1d5 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/history/FileHistory.kt +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/history/FileHistory.kt @@ -198,7 +198,7 @@ internal class FileHistoryRefiner(private val visibleLinearGraph: LinearGraph, namesData.getPathInParentRevision(previousCommit, permanentCommitsInfo.getCommitId(parentIndex), previousPath.filePath) } val path = findPathWithoutConflict(previousNodeId, pathGetter) - path ?: pathGetter(getCorrespondingParent(permanentLinearGraph, previousNodeId, currentNodeId, visibilityBuffer)) + path ?: pathGetter(permanentLinearGraph.getCorrespondingParent(previousNodeId, currentNodeId, visibilityBuffer)) } else { val pathGetter = { parentIndex: Int -> @@ -206,7 +206,7 @@ internal class FileHistoryRefiner(private val visibleLinearGraph: LinearGraph, } val path = findPathWithoutConflict(currentNodeId, pathGetter) // since in reality there is no edge between the nodes, but the whole path, we need to know, which parent is affected by this path - path ?: pathGetter(getCorrespondingParent(permanentLinearGraph, currentNodeId, previousNodeId, visibilityBuffer)) + path ?: pathGetter(permanentLinearGraph.getCorrespondingParent(currentNodeId, previousNodeId, visibilityBuffer)) } }