mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 06:50:54 +07:00
[lvcs] show all user labels after a change
Show the next event or user label that goes after a change, also show all the following user labels. GitOrigin-RevId: 8cc9932c2d8672bc7bd33b2aae903718e204e441
This commit is contained in:
committed by
intellij-monorepo-bot
parent
003d94586f
commit
994ea233d0
@@ -6,6 +6,7 @@ import com.intellij.history.ActivityPresentationProvider
|
||||
import com.intellij.history.core.*
|
||||
import com.intellij.history.core.changes.ChangeSet
|
||||
import com.intellij.history.core.changes.PutLabelChange
|
||||
import com.intellij.history.integration.CommonActivity
|
||||
import com.intellij.history.integration.IdeaGateway
|
||||
import com.intellij.history.integration.LocalHistoryImpl
|
||||
import com.intellij.openapi.extensions.ExtensionPointName
|
||||
@@ -64,17 +65,25 @@ internal class LocalHistoryActivityProvider(val project: Project, private val ga
|
||||
|
||||
private fun doLoadPathActivityList(projectId: String, scope: ActivityScope, path: String, scopeFilter: String?,
|
||||
affectedPaths: MutableSet<String>, activityItems: MutableList<ActivityItem>) {
|
||||
var lastLabel: ChangeSet? = null
|
||||
var lastEventLabel: ChangeSet? = null
|
||||
val userLabels = mutableListOf<ChangeSet>()
|
||||
facade.collectChanges(path, ChangeAndPathProcessor(projectId, scopeFilter, affectedPaths::add) { changeSet ->
|
||||
if (changeSet.isSystemLabelOnly) return@ChangeAndPathProcessor
|
||||
if (changeSet.isLabelOnly) {
|
||||
lastLabel = changeSet
|
||||
if (changeSet.activityId == CommonActivity.UserLabel) {
|
||||
userLabels.add(changeSet)
|
||||
lastEventLabel = null
|
||||
} else {
|
||||
lastEventLabel = changeSet
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (lastLabel != null) {
|
||||
activityItems.add(lastLabel!!.toActivityItem(scope))
|
||||
lastLabel = null
|
||||
}
|
||||
if (userLabels.isNotEmpty()) activityItems.addAll(userLabels.map { it.toActivityItem(scope) })
|
||||
if (lastEventLabel != null) activityItems.add(lastEventLabel!!.toActivityItem(scope))
|
||||
|
||||
userLabels.clear()
|
||||
lastEventLabel = null
|
||||
|
||||
activityItems.add(changeSet.toActivityItem(scope))
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.platform.lvcs.impl
|
||||
|
||||
import com.intellij.history.ActivityId
|
||||
import com.intellij.history.LocalHistory
|
||||
import com.intellij.history.integration.IntegrationTestCase
|
||||
import com.intellij.testFramework.HeavyPlatformTestCase
|
||||
@@ -61,6 +62,41 @@ class LocalHistoryActivityProviderTest : IntegrationTestCase() {
|
||||
TestCase.assertTrue(labelNames.intersect(listOf(systemLabel, hiddenUserLabel1, hiddenUserLabel2)).isEmpty())
|
||||
}
|
||||
|
||||
fun `test multiple event and user labels`() {
|
||||
val file = createFile("file.txt")
|
||||
|
||||
val activityId = ActivityId("dummyProvider", "dummyActivity")
|
||||
val localHistory = LocalHistory.getInstance()
|
||||
|
||||
setContent(file, "initial")
|
||||
val visibleEventLabel1 = "visible event label 1"
|
||||
localHistory.putEventLabel(project, visibleEventLabel1, activityId)
|
||||
val userLabel1 = "user label 1"
|
||||
localHistory.putUserLabel(project, userLabel1)
|
||||
localHistory.putEventLabel(project, "event label 1", activityId)
|
||||
val userLabel2 = "user label 2"
|
||||
localHistory.putUserLabel(project, userLabel2)
|
||||
|
||||
setContent(file, "content1")
|
||||
val visibleEventLabel2 = "visible event label 2"
|
||||
localHistory.putEventLabel(project, visibleEventLabel2, activityId)
|
||||
localHistory.putEventLabel(project, "hidden event label 1", activityId)
|
||||
|
||||
setContent(file, "content2")
|
||||
val userLabel3 = "user label 3"
|
||||
localHistory.putUserLabel(project, userLabel3)
|
||||
localHistory.putEventLabel(project, "hidden event label 2", activityId)
|
||||
localHistory.putEventLabel(project, "hidden event label 3", activityId)
|
||||
|
||||
val provider = LocalHistoryActivityProvider(project, gateway)
|
||||
val scope = ActivityScope.fromFile(file)
|
||||
|
||||
val activityList = provider.loadActivityList(scope, null)
|
||||
val labelNames = activityList.getLabelNameSet()
|
||||
|
||||
TestCase.assertEquals(listOf(userLabel1, userLabel2, userLabel3, visibleEventLabel1, visibleEventLabel2), labelNames.toList().sorted())
|
||||
}
|
||||
|
||||
fun `test directory`() {
|
||||
val directory = createDirectory("directory")
|
||||
val file = createChildData(directory, "file.txt")
|
||||
|
||||
Reference in New Issue
Block a user