From f6ea38766eb2defba8d830f2ecdb664d12987efa Mon Sep 17 00:00:00 2001 From: Konstantin Kolosovsky Date: Sun, 16 Jun 2019 23:26:54 +0300 Subject: [PATCH] vcs: Do not include changed blocks into commit by default * existing changes are not included by default on project open * unmodified files are not included after first modification GitOrigin-RevId: 98f428e3f64e304a568ef6a11a9975de8fcbf923 --- .../vcs/ex/PartialLocalLineStatusTracker.kt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/PartialLocalLineStatusTracker.kt b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/PartialLocalLineStatusTracker.kt index 1305de495153..0cd5d5004b8a 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/PartialLocalLineStatusTracker.kt +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/PartialLocalLineStatusTracker.kt @@ -8,6 +8,7 @@ import com.intellij.openapi.actionSystem.ActionManager import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.actionSystem.DefaultActionGroup import com.intellij.openapi.actionSystem.Separator +import com.intellij.openapi.application.ApplicationManager.getApplication import com.intellij.openapi.command.CommandEvent import com.intellij.openapi.command.CommandListener import com.intellij.openapi.command.CommandProcessor @@ -464,8 +465,15 @@ class ChangelistsLocalLineStatusTracker(project: Project, if (isValid()) eventDispatcher.multicaster.onBecomingValid(this@ChangelistsLocalLineStatusTracker) } - private fun mergeExcludedFromCommitRanges(ranges: List): Boolean { - if (ranges.isEmpty()) return false + private fun mergeExcludedFromCommitRanges(ranges: List): Boolean { + if (ranges.isEmpty()) { + if (getApplication().isUnitTestMode) return false + + val marker = currentMarker ?: defaultMarker + val changeListBlocks = blocks.filter { it.marker == marker } + // only include if all changed blocks from this change list are included + return changeListBlocks.isEmpty() || changeListBlocks.any { it.excludedFromCommit } + } return ranges.all { it.excludedFromCommit } } } @@ -856,7 +864,7 @@ class ChangelistsLocalLineStatusTracker(project: Project, protected data class MyBlockData(var marker: ChangeListMarker? = null, - var excludedFromCommit: Boolean = false + var excludedFromCommit: Boolean = !getApplication().isUnitTestMode ) : LineStatusTrackerBase.BlockData() override fun createBlockData(): BlockData = MyBlockData()