git-index: move three-side diff viewer to separate action

GitOrigin-RevId: dfb31b02561436848d43b9cd7adf1f3ffc54ac75
This commit is contained in:
Aleksey Pivovarov
2020-09-28 16:11:25 +00:00
committed by intellij-monorepo-bot
parent 21d02a97f0
commit 70bef3e687
3 changed files with 17 additions and 0 deletions
@@ -262,6 +262,7 @@
<action id="Git.Stage.AcceptTheirs" class="git4idea.index.actions.GitAcceptTheirsAction"/>
<action id="Git.Stage.AcceptYours" class="git4idea.index.actions.GitAcceptYoursAction"/>
<action id="Git.Stage.Merge" class="git4idea.index.actions.GitMergeConflictAction"/>
<action id="Git.Stage.ThreeSideDiff" class="git4idea.index.actions.GitStageThreeSideDiffAction" icon="AllIcons.Actions.Stub"/>
<action id="Git.Stash.Silently" class="git4idea.index.actions.GitStashSilentlyAction" icon="AllIcons.Vcs.ShelveSilent"/>
@@ -275,6 +276,7 @@
<reference id="Git.Stage.AcceptTheirs"/>
<reference id="Git.Stage.AcceptYours"/>
<reference id="Git.Stage.Add"/>
<reference id="Git.Stage.ThreeSideDiff"/>
<reference id="Git.Stage.Reset"/>
<reference id="Git.Stage.Revert"/>
<reference id="$Delete"/>
@@ -614,6 +614,7 @@ action.NotificationAction.GithubNotifications.text.configure=Configure...
action.NotificationAction.GitMergeAction.text.view.commits=View Commits
action.NotificationAction.GitRewordOperation.text.undo=Undo
action.NotificationAction.GitUpdateSession.text.view.commits=View Commits
action.Git.Stage.ThreeSideDiff.text=Add Interactively...
settings.git.option.group=Git
settings.commit.automatically.on.cherry.pick=Commit automatically on cherry-pick
@@ -5,9 +5,11 @@ import com.intellij.diff.DiffDialogHints
import com.intellij.diff.DiffManager
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.AnActionExtensionProvider
import com.intellij.openapi.project.DumbAwareAction
import com.intellij.openapi.vcs.changes.ui.ChangeDiffRequestChain
import com.intellij.util.containers.isEmpty
import git4idea.index.createThreeSidesDiffRequestProducer
import git4idea.index.createTwoSidesDiffRequestProducer
import git4idea.index.ui.GIT_FILE_STATUS_NODES_STREAM
import git4idea.index.ui.GIT_STAGE_TRACKER
import kotlin.streams.toList
@@ -20,6 +22,18 @@ class GitStageDiffAction : AnActionExtensionProvider {
e.presentation.isVisible = e.presentation.isEnabled || e.isFromActionToolbar
}
override fun actionPerformed(e: AnActionEvent) {
val producers = e.getRequiredData(GIT_FILE_STATUS_NODES_STREAM).map { createTwoSidesDiffRequestProducer(e.project!!, it) }.toList()
DiffManager.getInstance().showDiff(e.project, ChangeDiffRequestChain(producers, 0), DiffDialogHints.DEFAULT)
}
}
class GitStageThreeSideDiffAction : DumbAwareAction() {
override fun update(e: AnActionEvent) {
e.presentation.isEnabled = e.project != null && !e.getData(GIT_FILE_STATUS_NODES_STREAM).isEmpty()
e.presentation.isVisible = e.presentation.isEnabled || e.isFromActionToolbar
}
override fun actionPerformed(e: AnActionEvent) {
val producers = e.getRequiredData(GIT_FILE_STATUS_NODES_STREAM).map { createThreeSidesDiffRequestProducer(e.project!!, it) }.toList()
DiffManager.getInstance().showDiff(e.project, ChangeDiffRequestChain(producers, 0), DiffDialogHints.DEFAULT)