mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 17:03:12 +07:00
[file-history] exclude AdditionDeletions that were already processed
GitOrigin-RevId: b2a7185188a003c3968be2d9228239b2ffb2542b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
db9ac8f09c
commit
80a630296c
@@ -24,22 +24,25 @@ import java.util.*
|
||||
import java.util.function.BiConsumer
|
||||
|
||||
class FileHistory internal constructor(val commitsToPathsMap: Map<Int, MaybeDeletedFilePath>,
|
||||
internal val processedAdditionsDeletions: Set<AdditionDeletion>,
|
||||
internal val unmatchedAdditionsDeletions: Set<AdditionDeletion>,
|
||||
internal val commitToRename: MultiMap<UnorderedPair<Int>, Rename>) {
|
||||
constructor(commitsToPathsMap: Map<Int, MaybeDeletedFilePath>) : this(commitsToPathsMap, emptySet(), MultiMap.empty())
|
||||
constructor(commitsToPathsMap: Map<Int, MaybeDeletedFilePath>) : this(commitsToPathsMap, emptySet(), emptySet(), MultiMap.empty())
|
||||
}
|
||||
|
||||
internal val EMPTY_HISTORY = FileHistory(emptyMap())
|
||||
|
||||
internal class FileHistoryBuilder(private val startCommit: Int?,
|
||||
private val startPath: FilePath,
|
||||
private val fileHistoryData: FileHistoryData) : BiConsumer<LinearGraphController, PermanentGraphInfo<Int>> {
|
||||
private val fileHistoryData: FileHistoryData,
|
||||
private val oldFileHistory: FileHistory) : BiConsumer<LinearGraphController, PermanentGraphInfo<Int>> {
|
||||
private val pathsMap = mutableMapOf<Int, MaybeDeletedFilePath>()
|
||||
private val processedAdditionsDeletions = mutableSetOf<AdditionDeletion>()
|
||||
private val unmatchedAdditionsDeletions = mutableSetOf<AdditionDeletion>()
|
||||
private val commitToRename = MultiMap.createSmart<UnorderedPair<Int>, Rename>()
|
||||
|
||||
val fileHistory: FileHistory
|
||||
get() = FileHistory(pathsMap, unmatchedAdditionsDeletions, commitToRename)
|
||||
get() = FileHistory(pathsMap, processedAdditionsDeletions, unmatchedAdditionsDeletions, commitToRename)
|
||||
|
||||
override fun accept(controller: LinearGraphController, permanentGraphInfo: PermanentGraphInfo<Int>) {
|
||||
val needToRepeat = removeTrivialMerges(controller, permanentGraphInfo, fileHistoryData, this::reportTrivialMerges)
|
||||
@@ -56,9 +59,14 @@ internal class FileHistoryBuilder(private val startCommit: Int?,
|
||||
}
|
||||
|
||||
private fun collectAdditionsDeletions(controller: LinearGraphController, permanentGraphInfo: PermanentGraphInfo<Int>) {
|
||||
processedAdditionsDeletions.addAll(oldFileHistory.processedAdditionsDeletions)
|
||||
processedAdditionsDeletions.addAll(oldFileHistory.unmatchedAdditionsDeletions)
|
||||
|
||||
val additionsDeletions = mutableSetOf<AdditionDeletion>()
|
||||
fileHistoryData.iterateUnmatchedAdditionsDeletions { ad ->
|
||||
if (!processedAdditionsDeletions.contains(ad)) {
|
||||
additionsDeletions.add(ad)
|
||||
}
|
||||
}
|
||||
if (additionsDeletions.isNotEmpty()) {
|
||||
val grouped = additionsDeletions.groupBy { it.child }
|
||||
|
||||
@@ -175,7 +175,7 @@ internal class FileHistoryFilterer(logData: VcsLogData) : VcsLogFilterer {
|
||||
}
|
||||
|
||||
val commit = (hash ?: getHead(dataPack))?.let { storage.getCommitIndex(it, root) }
|
||||
val historyBuilder = FileHistoryBuilder(commit, filePath, data)
|
||||
val historyBuilder = FileHistoryBuilder(commit, filePath, data, oldVisiblePack.fileHistory)
|
||||
val visibleGraph = permanentGraph.createVisibleGraph(sortType, matchingHeads, data.getCommits(), historyBuilder)
|
||||
val fileHistory = historyBuilder.fileHistory
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class FileHistoryTest {
|
||||
val baseController = BaseController(permanentGraphInfo)
|
||||
val filteredController = object : FilteredController(baseController, permanentGraphInfo, fileNamesData.getCommits()) {}
|
||||
|
||||
val historyBuilder = FileHistoryBuilder(startCommit, startPath, fileNamesData)
|
||||
val historyBuilder = FileHistoryBuilder(startCommit, startPath, fileNamesData, EMPTY_HISTORY)
|
||||
historyBuilder.accept(filteredController, permanentGraphInfo)
|
||||
|
||||
val expectedResultGraph = graph(result)
|
||||
|
||||
Reference in New Issue
Block a user