diff --git a/platform/lvcs-api/src/com/intellij/history/LocalHistory.kt b/platform/lvcs-api/src/com/intellij/history/LocalHistory.kt index 36124ad6d705..113fe59a1f9e 100644 --- a/platform/lvcs-api/src/com/intellij/history/LocalHistory.kt +++ b/platform/lvcs-api/src/com/intellij/history/LocalHistory.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.history import com.intellij.openapi.application.ApplicationManager @@ -74,8 +74,7 @@ abstract class LocalHistory { /** * Puts a system label to mark a certain point in local history. - * Note that system labels added inside the [LocalHistoryAction] are not visible, - * also they are not visible in the experimental "Activity" tool window. + * Note that system labels can be visible or not depending on the UI settings. * * @param project the project where the event occurred * @param name the name of the label @@ -86,8 +85,7 @@ abstract class LocalHistory { /** * Puts a system label to mark a certain point in local history. - * Note that system labels added inside the [LocalHistoryAction] are not visible, - * also they are not visible in the experimental "Activity" tool window. + * Note that system labels can be visible or not depending on the UI settings. * * @param project the project where the event occurred * @param name the name of the label diff --git a/platform/lvcs-impl/resources/intellij.platform.lvcs.impl.xml b/platform/lvcs-impl/resources/intellij.platform.lvcs.impl.xml index bdd543dffd4e..1a494bdffc0c 100644 --- a/platform/lvcs-impl/resources/intellij.platform.lvcs.impl.xml +++ b/platform/lvcs-impl/resources/intellij.platform.lvcs.impl.xml @@ -52,10 +52,15 @@ + + + + diff --git a/platform/lvcs-impl/resources/messages/LocalHistoryBundle.properties b/platform/lvcs-impl/resources/messages/LocalHistoryBundle.properties index f43394e3787c..b51689d2845b 100644 --- a/platform/lvcs-impl/resources/messages/LocalHistoryBundle.properties +++ b/platform/lvcs-impl/resources/messages/LocalHistoryBundle.properties @@ -93,6 +93,8 @@ activity.action.patch.collecting.diff=Collecting Differences action.ActivityView.Revert.text=Revert Selected and Later Changes action.ActivityView.RevertDifferences.text=Revert Selection action.ActivityView.CreatePatch.text=Create Patch\u2026 +group.ActivityView.Options.text=View Options +action.ActivityView.ShowSystemLabelsAction.text=Show System Events # notifications notification.group.general=Local history messages @@ -104,4 +106,4 @@ notification.content.label.creation.failed=Could not create label {0} # used externally dialog.title.revert=Revert -message.do.you.want.to.proceed={0}\n\nDo you want to proceed? \ No newline at end of file +message.do.you.want.to.proceed={0}\n\nDo you want to proceed? diff --git a/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/ActivityProvider.kt b/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/ActivityProvider.kt index 3f201c1b5e7b..195850e9257a 100644 --- a/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/ActivityProvider.kt +++ b/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/ActivityProvider.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 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.diff.chains.DiffRequestProducer @@ -9,8 +9,8 @@ import org.jetbrains.annotations.ApiStatus interface ActivityProvider { fun getActivityItemsChanged(scope: ActivityScope): Flow - fun loadActivityList(scope: ActivityScope, fileFilter: String?): ActivityData - fun filterActivityList(scope: ActivityScope, data: ActivityData, contentFilter: String?): Set? + fun loadActivityList(scope: ActivityScope, fileFilter: String?, showSystemLabels: Boolean): ActivityData + fun filterActivityList(scope: ActivityScope, data: ActivityData, contentFilter: String?, showSystemLabels: Boolean): Set? fun loadDiffData(scope: ActivityScope, selection: ActivitySelection, diffMode: DirectoryDiffMode): ActivityDiffData? fun loadSingleDiff(scope: ActivityScope, selection: ActivitySelection): DiffRequestProducer? @@ -28,4 +28,4 @@ enum class FilterKind { @ApiStatus.Experimental enum class DirectoryDiffMode { WithLocal, WithNext -} \ No newline at end of file +} diff --git a/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/ChangeSetActivityItem.kt b/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/ChangeSetActivityItem.kt index 59d949aa1ff1..d83a88f6ca6f 100644 --- a/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/ChangeSetActivityItem.kt +++ b/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/ChangeSetActivityItem.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. @file:ApiStatus.Internal package com.intellij.platform.lvcs.impl @@ -14,13 +14,15 @@ import com.intellij.util.text.DateFormatUtil import org.jetbrains.annotations.ApiStatus @ApiStatus.Internal -abstract class ChangeSetActivityItem(changeSet: ChangeSet) : ActivityItem { +abstract class ChangeSetActivityItem(private val changeSet: ChangeSet) : ActivityItem { override val timestamp: Long = changeSet.timestamp val id = changeSet.id val activityId: ActivityId? = changeSet.activityId open val fullName: @NlsSafe String? get() = name abstract val name: @NlsSafe String? + fun isSystemLabelOnly(): Boolean = changeSet.isSystemLabelOnly + override fun equals(other: Any?): Boolean { if (this === other) return true if (other !is ChangeSetActivityItem) return false @@ -91,4 +93,4 @@ internal class LabelActivityItem(changeSet: ChangeSet) : ChangeSetActivityItem(c fun ChangeSet.toActivityItem(scope: ActivityScope): ActivityItem { if (isLabelOnly) return LabelActivityItem(this) return ChangeActivityItem(this, scope) -} \ No newline at end of file +} diff --git a/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/LocalHistoryActivityProvider.kt b/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/LocalHistoryActivityProvider.kt index 97567a0d958f..d41d5abbc880 100644 --- a/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/LocalHistoryActivityProvider.kt +++ b/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/LocalHistoryActivityProvider.kt @@ -13,7 +13,6 @@ import com.intellij.openapi.extensions.ExtensionPointName import com.intellij.openapi.project.BaseProjectDirectories.Companion.getBaseDirectories import com.intellij.openapi.project.Project import com.intellij.openapi.util.Disposer -import com.intellij.openapi.util.registry.Registry import com.intellij.platform.lvcs.impl.diff.createDiffData import com.intellij.platform.lvcs.impl.diff.createSingleFileDiffRequestProducer import kotlinx.coroutines.channels.awaitClose @@ -30,46 +29,45 @@ internal class LocalHistoryActivityProvider(val project: Project, private val ga return facade.onChangeSetFinished(project, gateway, scope) } - override fun loadActivityList(scope: ActivityScope, fileFilter: String?): ActivityData { + override fun loadActivityList(scope: ActivityScope, fileFilter: String?, showSystemLabels: Boolean): ActivityData { gateway.registerUnsavedDocuments(facade) val filter = HistoryPathFilter.create(fileFilter, project) val projectId = project.locationHash if (scope is ActivityScope.File) { - return loadFileActivityList(projectId, scope, filter) + return loadFileActivityList(projectId, scope, filter, showSystemLabels) } else if (scope is ActivityScope.Files) { - return loadFilesActivityList(projectId, scope, filter) + return loadFilesActivityList(projectId, scope, filter, showSystemLabels) } - return loadRecentActivityList(projectId, scope, filter) + return loadRecentActivityList(projectId, scope, filter, showSystemLabels) } - private fun loadFileActivityList(projectId: String, scope: ActivityScope.File, scopeFilter: HistoryPathFilter?): ActivityData { + private fun loadFileActivityList(projectId: String, scope: ActivityScope.File, scopeFilter: HistoryPathFilter?, showSystemLabels: Boolean): ActivityData { val path = gateway.getPathOrUrl(scope.file) val activityItems = mutableListOf() val affectedPaths = mutableSetOf(path) - doLoadPathActivityList(projectId, scope, path, scopeFilter, affectedPaths, activityItems) + doLoadPathActivityList(projectId, scope, path, scopeFilter, affectedPaths, activityItems, showSystemLabels) return ActivityData(activityItems).also { it.putUserData(AFFECTED_PATHS, affectedPaths) } } - private fun loadFilesActivityList(projectId: String, scope: ActivityScope.Files, scopeFilter: HistoryPathFilter?): ActivityData { + private fun loadFilesActivityList(projectId: String, scope: ActivityScope.Files, scopeFilter: HistoryPathFilter?, showSystemLabels: Boolean): ActivityData { val paths = scope.files.map { gateway.getPathOrUrl(it) } val activityItems = mutableListOf() val affectedPaths = paths.toMutableSet() for (path in paths) { - doLoadPathActivityList(projectId, scope, path, scopeFilter, affectedPaths, activityItems) + doLoadPathActivityList(projectId, scope, path, scopeFilter, affectedPaths, activityItems, showSystemLabels) } return ActivityData(activityItems.toSet().sortedByDescending { it.timestamp }).also { it.putUserData(AFFECTED_PATHS, affectedPaths) } } private fun doLoadPathActivityList(projectId: String, scope: ActivityScope, path: String, scopeFilter: HistoryPathFilter?, - affectedPaths: MutableSet, activityItems: MutableList) { + affectedPaths: MutableSet, activityItems: MutableList, showSystemLabels: Boolean) { var lastEventLabel: ChangeSet? = null val userLabels = mutableListOf() - val showSystemLabels = Registry.`is`("lvcs.show.system.labels.in.activity.view") facade.collectChanges(path, ChangeAndPathProcessor(projectId, scopeFilter, affectedPaths::add) { changeSet -> if (!showSystemLabels && changeSet.isSystemLabelOnly) return@ChangeAndPathProcessor @@ -95,10 +93,9 @@ internal class LocalHistoryActivityProvider(val project: Project, private val ga }) } - private fun loadRecentActivityList(projectId: String, scope: ActivityScope, fileFilter: HistoryPathFilter?): ActivityData { + private fun loadRecentActivityList(projectId: String, scope: ActivityScope, fileFilter: HistoryPathFilter?, showSystemLabels: Boolean): ActivityData { val result = mutableListOf() val paths = project.getBaseDirectories().map { gateway.getPathOrUrl(it) } - val showSystemLabels = Registry.`is`("lvcs.show.system.labels.in.activity.view") for (changeSet in facade.changes) { if (!showSystemLabels && changeSet.isSystemLabelOnly) continue @@ -115,14 +112,14 @@ internal class LocalHistoryActivityProvider(val project: Project, private val ga return ActivityData(result).also { it.putUserData(AFFECTED_PATHS, paths) } } - override fun filterActivityList(scope: ActivityScope, data: ActivityData, contentFilter: String?): Set? { + override fun filterActivityList(scope: ActivityScope, data: ActivityData, contentFilter: String?, showSystemLabels: Boolean): Set? { val changeSets = data.getChangeSets() - if (contentFilter.isNullOrEmpty() || changeSets.isEmpty()) return null + if (changeSets.isEmpty()) return null val fileScope = scope as? ActivityScope.File ?: return null val filteredIds = mutableSetOf() val processor: (Long, String?) -> Boolean = { changeSetId, content -> - if (content?.contains(contentFilter, true) == true) filteredIds.add(changeSetId) + if (contentFilter == null || content?.contains(contentFilter, true) == true) filteredIds.add(changeSetId) true } @@ -135,7 +132,14 @@ internal class LocalHistoryActivityProvider(val project: Project, private val ga facade.processContents(gateway, rootEntry, path, changeSets, before = USE_OLD_CONTENT, processor = processor) } - return data.items.filterTo(mutableSetOf()) { (it is ChangeSetActivityItem) && filteredIds.contains(it.id) } + val result = mutableSetOf() + for (item in data.items) { + when { + !showSystemLabels && item is ChangeSetActivityItem && item.isSystemLabelOnly() -> continue + item is ChangeSetActivityItem && filteredIds.contains(item.id) -> result.add(item) + } + } + return result } override fun loadDiffData(scope: ActivityScope, selection: ActivitySelection, diffMode: DirectoryDiffMode): ActivityDiffData? { diff --git a/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/actions/ShowSystemLabelsAction.kt b/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/actions/ShowSystemLabelsAction.kt new file mode 100644 index 000000000000..63107b57a04a --- /dev/null +++ b/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/actions/ShowSystemLabelsAction.kt @@ -0,0 +1,27 @@ +// Copyright 2000-2025 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.actions + +import com.intellij.openapi.actionSystem.ActionUpdateThread +import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.actionSystem.ToggleAction +import com.intellij.openapi.components.service +import com.intellij.openapi.project.DumbAware +import com.intellij.platform.lvcs.impl.settings.ActivityViewApplicationSettings +import com.intellij.platform.lvcs.impl.ui.ActivityViewDataKeys + +internal class ShowSystemLabelsAction: ToggleAction(), DumbAware { + + override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.EDT + + override fun isSelected(e: AnActionEvent): Boolean { + return isShowSystemLabelsEnabled() + } + + override fun setSelected(e: AnActionEvent, state: Boolean) { + service().showSystemLabels = state + e.getData(ActivityViewDataKeys.ACTIVITY_VIEW_MODEL)?.setSystemLabelsFiltered(state) + } +} + +internal fun isShowSystemLabelsEnabled(): Boolean = + service().showSystemLabels diff --git a/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/settings/ActivityViewApplicationSettings.kt b/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/settings/ActivityViewApplicationSettings.kt index 033afc3ced7d..c20ac4cec085 100644 --- a/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/settings/ActivityViewApplicationSettings.kt +++ b/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/settings/ActivityViewApplicationSettings.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 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.settings import com.intellij.openapi.Disposable @@ -13,6 +13,7 @@ internal class ActivityViewApplicationSettings : SimplePersistentStateComponent< class State : BaseState() { var diffMode by enum(DirectoryDiffMode.WithLocal) + var showSystemLabels by property(true) } var diffMode: DirectoryDiffMode @@ -22,6 +23,13 @@ internal class ActivityViewApplicationSettings : SimplePersistentStateComponent< eventDispatcher.multicaster.settingsChanged() } + var showSystemLabels: Boolean + get() = state.showSystemLabels + set(value) { + state.showSystemLabels = value + eventDispatcher.multicaster.settingsChanged() + } + fun addListener(listener: Listener, disposable: Disposable) { eventDispatcher.addListener(listener, disposable) } @@ -29,4 +37,4 @@ internal class ActivityViewApplicationSettings : SimplePersistentStateComponent< interface Listener : EventListener { fun settingsChanged() } -} \ No newline at end of file +} diff --git a/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/ui/ActivityView.kt b/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/ui/ActivityView.kt index 7b27fd14c0a0..0eb0f19ae864 100644 --- a/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/ui/ActivityView.kt +++ b/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/ui/ActivityView.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 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.ui import com.intellij.diff.editor.DiffEditorTabFilesManager @@ -173,6 +173,7 @@ class ActivityView(private val project: Project, gateway: IdeaGateway, val activ sink[ActivityViewDataKeys.SCOPE] = activityScope sink[DiffDataKeys.EDITOR_TAB_DIFF_PREVIEW] = editorDiffPreview sink[ActivityViewDataKeys.DIRECTORY_DIFF_MODE] = model.diffMode + sink[ActivityViewDataKeys.ACTIVITY_VIEW_MODEL] = model } val preferredFocusedComponent: JComponent get() = activityList @@ -399,4 +400,4 @@ private sealed interface SearchFieldComponent { override val containerComponent = SearchTextArea(textArea, true) override val textComponent = textArea } -} \ No newline at end of file +} diff --git a/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/ui/ActivityViewDataKeys.kt b/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/ui/ActivityViewDataKeys.kt index b2f5b3589e23..87a1eddec93b 100644 --- a/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/ui/ActivityViewDataKeys.kt +++ b/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/ui/ActivityViewDataKeys.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 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.ui import com.intellij.openapi.actionSystem.DataKey @@ -14,4 +14,5 @@ object ActivityViewDataKeys { val SCOPE: DataKey = DataKey.create("ActivityView.Scope") val SELECTED_DIFFERENCES: DataKey> = DataKey.create("ActivityView.SelectedDifferences") val DIRECTORY_DIFF_MODE: DataKey = DataKey.create("ActivityView.DirectoryDiffMode") -} \ No newline at end of file + internal val ACTIVITY_VIEW_MODEL: DataKey = DataKey.create("ActivityView.ActivityViewModel") +} diff --git a/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/ui/ActivityViewModel.kt b/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/ui/ActivityViewModel.kt index 594e06e40e32..ba32d669042b 100644 --- a/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/ui/ActivityViewModel.kt +++ b/platform/lvcs-impl/src/com/intellij/platform/lvcs/impl/ui/ActivityViewModel.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 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.ui import com.intellij.history.integration.IdeaGateway @@ -7,6 +7,7 @@ import com.intellij.openapi.application.EDT import com.intellij.openapi.diagnostic.thisLogger import com.intellij.openapi.project.Project import com.intellij.platform.lvcs.impl.* +import com.intellij.platform.lvcs.impl.actions.isShowSystemLabelsEnabled import com.intellij.platform.lvcs.impl.statistics.LocalHistoryCounter import com.intellij.util.EventDispatcher import com.intellij.util.concurrency.annotations.RequiresEdt @@ -27,21 +28,24 @@ internal class ActivityViewModel(private val project: Project, gateway: IdeaGate private val filterFlow = MutableStateFlow(null) + private val filterSystemLabelsFlow = MutableStateFlow(isShowSystemLabelsEnabled()) + private val isVisibleFlow = MutableStateFlow(true) init { coroutineScope.launch { combine(activityProvider.getActivityItemsChanged(activityScope).debounce(500), if (filterKind == FilterKind.FILE) filterFlow else flowOf(null), - isVisibleFlow) { _, filter, isVisible -> filter to isVisible } - .filter { (_, isVisible) -> isVisible } - .map { it.first } - .collect { filter -> + isVisibleFlow, + filterSystemLabelsFlow.debounce(100)) { _, filter, isVisible, showSystemLabels -> Triple(filter, isVisible, showSystemLabels) } + .filter { (_, isVisible, _) -> isVisible } + .map { it.first to it.third } + .collect { (filter, showSystemLabels) -> thisLogger().debug("Loading activity items for $activityScope and filter $filter") withContext(Dispatchers.EDT) { eventDispatcher.multicaster.onItemsLoadingStarted() } val activityData = withContext(Dispatchers.Default) { LocalHistoryCounter.logLoadItems(project, activityScope) { - activityProvider.loadActivityList(activityScope, filter) + activityProvider.loadActivityList(activityScope, filter, showSystemLabels) } } withContext(Dispatchers.EDT) { @@ -73,19 +77,17 @@ internal class ActivityViewModel(private val project: Project, gateway: IdeaGate if (filterKind == FilterKind.CONTENT) { coroutineScope.launch { - combine(filterFlow.debounce(100), activityItemsFlow) { f, r -> f to r }.collect { (filter, data) -> - if (filter.isNullOrEmpty()) { - withContext(Dispatchers.EDT) { eventDispatcher.multicaster.onFilteringStopped(null) } - return@collect + combine(filterFlow.debounce(100), + filterSystemLabelsFlow.debounce(100), + activityItemsFlow) { ff, fs, r -> Triple(ff, fs, r) } + .collect { (filter, showSystemLabels, data) -> + thisLogger().debug("Filtering activity items for $activityScope by $filter") + withContext(Dispatchers.EDT) { eventDispatcher.multicaster.onFilteringStarted() } + val result = LocalHistoryCounter.logFilter(project, activityScope) { + activityProvider.filterActivityList(activityScope, data, filter, showSystemLabels) + } + withContext(Dispatchers.EDT) { eventDispatcher.multicaster.onFilteringStopped(result) } } - - thisLogger().debug("Filtering activity items for $activityScope by $filter") - withContext(Dispatchers.EDT) { eventDispatcher.multicaster.onFilteringStarted() } - val result = LocalHistoryCounter.logFilter(project, activityScope) { - activityProvider.filterActivityList(activityScope, data, filter) - } - withContext(Dispatchers.EDT) { eventDispatcher.multicaster.onFilteringStopped(result) } - } } } } @@ -105,6 +107,10 @@ internal class ActivityViewModel(private val project: Project, gateway: IdeaGate filterFlow.value = pattern } + fun setSystemLabelsFiltered(filtered: Boolean) { + filterSystemLabelsFlow.value = filtered + } + @RequiresEdt fun setSelection(selection: ActivitySelection?) { selectionFlow.value = selection @@ -128,4 +134,4 @@ internal interface ActivityModelListener : EventListener { fun onDiffDataLoadingStopped(diffData: ActivityDiffData?) = Unit fun onFilteringStarted() = Unit fun onFilteringStopped(result: Set?) = Unit -} \ No newline at end of file +} diff --git a/platform/lvcs-impl/testSrc/com/intellij/platform/lvcs/impl/LocalHistoryActivityProviderTest.kt b/platform/lvcs-impl/testSrc/com/intellij/platform/lvcs/impl/LocalHistoryActivityProviderTest.kt index 3ff8c5e5aeb1..beb084bb384c 100644 --- a/platform/lvcs-impl/testSrc/com/intellij/platform/lvcs/impl/LocalHistoryActivityProviderTest.kt +++ b/platform/lvcs-impl/testSrc/com/intellij/platform/lvcs/impl/LocalHistoryActivityProviderTest.kt @@ -4,15 +4,24 @@ 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.openapi.util.registry.Registry +import com.intellij.openapi.components.service +import com.intellij.openapi.util.Disposer +import com.intellij.platform.lvcs.impl.settings.ActivityViewApplicationSettings import com.intellij.testFramework.HeavyPlatformTestCase +import com.intellij.util.application import junit.framework.TestCase class LocalHistoryActivityProviderTest : IntegrationTestCase() { + + private val showSystemLabels get() = application.service().showSystemLabels + override fun setUp() { super.setUp() - Registry.get("lvcs.show.system.labels.in.activity.view").setValue(false, testRootDisposable) + val applicationSettings = application.service() + val prev = applicationSettings.showSystemLabels + applicationSettings.showSystemLabels = false + Disposer.register(testRootDisposable) { applicationSettings.showSystemLabels = prev } } fun `test single file`() { @@ -30,13 +39,13 @@ class LocalHistoryActivityProviderTest : IntegrationTestCase() { val provider = LocalHistoryActivityProvider(project, gateway) val scope = ActivityScope.fromFile(file) - val fileActivity = provider.loadActivityList(scope, null) + val fileActivity = provider.loadActivityList(scope, null, showSystemLabels) TestCase.assertEquals(/* file created + content changes */contents.size + 1, fileActivity.items.size) val activityContents = getContentFor(file, fileActivity.getChangeSets()) TestCase.assertEquals(/* content before change happened */listOf("") + contents.dropLast(1), activityContents.reversed()) - val filteredActivity = provider.filterActivityList(scope, fileActivity, keyword) + val filteredActivity = provider.filterActivityList(scope, fileActivity, keyword, showSystemLabels) TestCase.assertEquals(fileActivity.items[2], filteredActivity?.single()) } @@ -62,7 +71,7 @@ class LocalHistoryActivityProviderTest : IntegrationTestCase() { val provider = LocalHistoryActivityProvider(project, gateway) val scope = ActivityScope.fromFile(file) - val activityList = provider.loadActivityList(scope, null) + val activityList = provider.loadActivityList(scope, null, showSystemLabels) val labelNames = activityList.getLabelNameSet() TestCase.assertTrue(labelNames.containsAll(listOf(userLabel, visibleUserLabel))) @@ -98,7 +107,7 @@ class LocalHistoryActivityProviderTest : IntegrationTestCase() { val provider = LocalHistoryActivityProvider(project, gateway) val scope = ActivityScope.fromFile(file) - val activityList = provider.loadActivityList(scope, null) + val activityList = provider.loadActivityList(scope, null, showSystemLabels) val labelNames = activityList.getLabelNameSet() TestCase.assertEquals(listOf(userLabel1, userLabel2, userLabel3, visibleEventLabel1, visibleEventLabel2), labelNames.toList().sorted()) @@ -119,7 +128,7 @@ class LocalHistoryActivityProviderTest : IntegrationTestCase() { val provider = LocalHistoryActivityProvider(project, gateway) val scope = ActivityScope.fromFile(directory) - val directoryActivity = provider.loadActivityList(scope, null) + val directoryActivity = provider.loadActivityList(scope, null, showSystemLabels) TestCase.assertEquals(4, directoryActivity.items.size) TestCase.assertEquals(listOf("label", "Modify ${file.name}", @@ -149,14 +158,14 @@ class LocalHistoryActivityProviderTest : IntegrationTestCase() { val provider = LocalHistoryActivityProvider(project, gateway) val scope = ActivityScope.Recent - val activityList = provider.loadActivityList(scope, null) + val activityList = provider.loadActivityList(scope, null, showSystemLabels) val labelNames = activityList.getLabelNameSet() TestCase.assertTrue(labelNames.containsAll(listOf(label1, label2))) TestCase.assertTrue(labelNames.intersect(listOf(systemLabel, otherProjectLabel)).isEmpty()) for (f in listOf(file, otherFile)) { - val fileActivity = provider.loadActivityList(scope, file.name) + val fileActivity = provider.loadActivityList(scope, file.name, showSystemLabels) TestCase.assertEquals(3, fileActivity.items.size) val activityContents = getContentFor(file, fileActivity.getChangeSets()) @@ -183,7 +192,7 @@ class LocalHistoryActivityProviderTest : IntegrationTestCase() { val provider = LocalHistoryActivityProvider(project, gateway) val scope = ActivityScope.fromFiles(listOf(file, otherFile)) - val activityList = provider.loadActivityList(scope, null) + val activityList = provider.loadActivityList(scope, null, showSystemLabels) TestCase.assertEquals(listOf(visibleLabel, "Modify ${otherFile.name}", @@ -212,7 +221,7 @@ class LocalHistoryActivityProviderTest : IntegrationTestCase() { val provider = LocalHistoryActivityProvider(project, gateway) val scope = ActivityScope.fromFiles(listOf(file, directory)) - val activityList = provider.loadActivityList(scope, null) + val activityList = provider.loadActivityList(scope, null, showSystemLabels) TestCase.assertEquals(listOf("Modify ${file.name}", moveActionName, @@ -233,7 +242,7 @@ class LocalHistoryActivityProviderTest : IntegrationTestCase() { val provider = LocalHistoryActivityProvider(project, gateway) val scope = ActivityScope.fromFiles(listOf(myRoot)) - val activityList = provider.loadActivityList(scope, null) + val activityList = provider.loadActivityList(scope, null, showSystemLabels) TestCase.assertEquals(listOf("MODIFIED:${file.name}"), getDiffDataForSelection(provider, scope, activityList, 0, 1)) TestCase.assertEquals(listOf("ADDED:${innerDirectory.name}"), getDiffDataForSelection(provider, scope, activityList, 1, 2)) diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index 37e3383e04f2..ffaa8b6e7179 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -809,8 +809,6 @@ lvcs.show.activity.view=true lvcs.show.activity.view.description=Show new ui for the "Local History" lvcs.open.diff.automatically=true lvcs.open.diff.automatically.description=Open diff tab (if it is configured to be opened in the editor) when "Local History" tab is shown. -lvcs.show.system.labels.in.activity.view=true -lvcs.show.system.labels.in.activity.view.description=If true, show system labels in activity view such as "Tests Passed/Failed", "Shelve changes", etc. vcs.showConsole=true vcs.showConsole.description=Show 'Console' tab in VCS toolwindow that logs all write-commands performed by IDE.