[vcs] IJPL-160705 Add path in titles of patch viewer

GitOrigin-RevId: e80d53cc5dc8a64d0d3f515e1646ec1f10080285
This commit is contained in:
Ilia.Shulgin
2024-08-21 23:14:51 +02:00
committed by intellij-monorepo-bot
parent 0c919ea6b4
commit 2af2e7ca41
3 changed files with 23 additions and 10 deletions

View File

@@ -5982,6 +5982,7 @@ f:com.intellij.openapi.vcs.history.DiffTitleFilePathCustomizer
- sf:INSTANCE:com.intellij.openapi.vcs.history.DiffTitleFilePathCustomizer
- sf:getTitleCustomizers(com.intellij.openapi.project.Project,com.intellij.openapi.vcs.history.DiffTitleFilePathCustomizer$RevisionWithTitle,com.intellij.openapi.vcs.history.DiffTitleFilePathCustomizer$RevisionWithTitle):java.util.List
- sf:getTitleCustomizers(com.intellij.openapi.project.Project,com.intellij.openapi.vcs.history.DiffTitleFilePathCustomizer$RevisionWithTitle,com.intellij.openapi.vcs.history.DiffTitleFilePathCustomizer$RevisionWithTitle,com.intellij.openapi.vcs.history.DiffTitleFilePathCustomizer$RevisionWithTitle):java.util.List
- sf:getTitleCustomizers(java.lang.String,java.lang.String):java.util.List
f:com.intellij.openapi.vcs.history.DiffTitleFilePathCustomizer$RevisionWithTitle
- sf:Companion:com.intellij.openapi.vcs.history.DiffTitleFilePathCustomizer$RevisionWithTitle$Companion
- <init>(com.intellij.openapi.vcs.changes.ContentRevision,java.lang.String):V

View File

@@ -38,6 +38,7 @@ import com.intellij.openapi.vcs.changes.actions.diff.prepareCombinedBlocksFromPr
import com.intellij.openapi.vcs.changes.patch.PatchFileType
import com.intellij.openapi.vcs.changes.ui.ChangeDiffRequestChain
import com.intellij.openapi.vcs.changes.ui.MutableDiffRequestChainProcessor
import com.intellij.openapi.vcs.history.DiffTitleFilePathCustomizer.getTitleCustomizers
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.SingleRootFileViewProvider
import com.intellij.util.ui.update.MergingUpdateQueue
@@ -172,7 +173,10 @@ private class PatchDiffRequestProducer(private val patch: FilePatch) : ChangeDif
@Throws(ProcessCanceledException::class)
override fun process(context: UserDataHolder, indicator: ProgressIndicator): DiffRequest {
if (patch is TextFilePatch) {
return PatchDiffRequest(patch, null, patch.beforeName, patch.afterName)
val patchDiffRequest = PatchDiffRequest(patch, null, patch.beforeName, patch.afterName)
return DiffUtil.addTitleCustomizers(
patchDiffRequest, getTitleCustomizers(patchDiffRequest.patch.beforeName, patchDiffRequest.patch.afterName)
)
}
if (patch is BinaryFilePatch) {
return MessageDiffRequest(VcsBundle.message("patch.is.binary.text"))

View File

@@ -14,15 +14,23 @@ import com.intellij.ui.components.JBLabel
import com.intellij.vcsUtil.VcsUtil
object DiffTitleFilePathCustomizer {
private val EMPTY_CUSTOMIZER = DiffEditorTitleCustomizer { null }
@JvmStatic
fun getTitleCustomizers(
project: Project?,
beforeRevision: RevisionWithTitle?,
afterRevision: RevisionWithTitle?,
): List<DiffEditorTitleCustomizer> = buildList {
add(getTitleCustomizer(beforeRevision, project))
add(getTitleCustomizer(afterRevision, project, showPath = beforeRevision == null || beforeRevision.revision.file != afterRevision?.revision?.file))
}
): List<DiffEditorTitleCustomizer> = listOf(
getTitleCustomizer(beforeRevision, project),
getTitleCustomizer(afterRevision, project, showPath = beforeRevision == null || beforeRevision.revision.file != afterRevision?.revision?.file),
)
@JvmStatic
fun getTitleCustomizers(beforeFilePath: String?, afterFilePath: String?): List<DiffEditorTitleCustomizer> = listOf(
beforeFilePath?.let { FilePathDiffTitleCustomizer(beforeFilePath) } ?: EMPTY_CUSTOMIZER,
afterFilePath?.let { FilePathDiffTitleCustomizer(afterFilePath) } ?: EMPTY_CUSTOMIZER,
)
@JvmStatic
fun getTitleCustomizers(
@@ -30,11 +38,11 @@ object DiffTitleFilePathCustomizer {
beforeRevision: RevisionWithTitle?,
centerRevision: RevisionWithTitle?,
afterRevision: RevisionWithTitle?,
): List<DiffEditorTitleCustomizer> = buildList {
add(getTitleCustomizer(beforeRevision, project, showPath = centerRevision == null || centerRevision.revision.file != beforeRevision?.revision?.file))
add(getTitleCustomizer(centerRevision, project))
add(getTitleCustomizer(afterRevision, project, showPath = centerRevision == null || centerRevision.revision.file != afterRevision?.revision?.file))
}
): List<DiffEditorTitleCustomizer> = listOf(
getTitleCustomizer(beforeRevision, project, showPath = centerRevision == null || centerRevision.revision.file != beforeRevision?.revision?.file),
getTitleCustomizer(centerRevision, project),
getTitleCustomizer(afterRevision, project, showPath = centerRevision == null || centerRevision.revision.file != afterRevision?.revision?.file),
)
private fun getTitleCustomizer(
revision: RevisionWithTitle?,