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
This commit is contained in:
Konstantin Kolosovsky
2019-07-02 06:52:16 +03:00
committed by intellij-monorepo-bot
parent 5a994ff593
commit f6ea38766e
@@ -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<DocumentTracker.Block>): Boolean {
if (ranges.isEmpty()) return false
private fun mergeExcludedFromCommitRanges(ranges: List<Block>): 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()