commit - ba7062dfbcc4fbe591ab7ce9766e2e1a09a837a8
commit + b462f47784c7203ab8c1953668f7f02818d9d4f8
blob - aa3ca7d9f9e8d1e61942a98c450ac8363ad603ca
blob + 494b3a993df8f194bef0aa5676fcf7ab47891285
--- src/main/kotlin/dev/nezzontli/gotvcs/GotChangeProvider.kt
+++ src/main/kotlin/dev/nezzontli/gotvcs/GotChangeProvider.kt
import com.intellij.openapi.vcs.changes.ChangelistBuilder
import com.intellij.openapi.vcs.changes.CurrentContentRevision
import com.intellij.openapi.vcs.changes.LocallyDeletedChange
+import com.intellij.openapi.vcs.VcsException
import com.intellij.openapi.vcs.changes.VcsDirtyScope
+import com.intellij.openapi.vcs.history.VcsRevisionNumber
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.vcsUtil.VcsUtil
import java.io.File
for (root in dirtyScope.affectedContentRoots) {
val workDir = File(root.path)
val entries = commandLine.status(workDir)
+ if (entries.isEmpty()) continue
+ // Resuelto una vez por raíz (fuera del EDT): GotContentRevision no
+ // puede recalcularlo perezosamente, ver su comentario de clase.
+ val baseRevision: VcsRevisionNumber = try {
+ GotRevisionNumber(commandLine.baseCommit(workDir))
+ } catch (e: VcsException) {
+ VcsRevisionNumber.NULL
+ }
+
for (entry in entries) {
val absoluteFile = File(workDir, entry.path)
val filePath = VcsUtil.getFilePath(absoluteFile, false)
'M', 'm', 'C' -> {
val status = if (entry.code == 'C') FileStatus.MERGED_WITH_CONFLICTS else FileStatus.MODIFIED
- val before = GotContentRevision(filePath, workDir, entry.path, commandLine)
+ val before = GotContentRevision(filePath, workDir, entry.path, commandLine, baseRevision)
val after = CurrentContentRevision(filePath)
builder.processChange(Change(before, after, status), GotVcs.getKey())
}
}
'D' -> {
- val before = GotContentRevision(filePath, workDir, entry.path, commandLine)
+ val before = GotContentRevision(filePath, workDir, entry.path, commandLine, baseRevision)
builder.processChange(Change(before, null, FileStatus.DELETED), GotVcs.getKey())
}
blob - 2b11afcff5ba20367d7e32ba7829e39a6fc8cb26
blob + 7cdb19a1b16ac2c0ad4a1bddcf2cf0c271649cdd
--- src/main/kotlin/dev/nezzontli/gotvcs/GotContentRevision.kt
+++ src/main/kotlin/dev/nezzontli/gotvcs/GotContentRevision.kt
import com.intellij.openapi.vcs.history.VcsRevisionNumber
import java.io.File
-/** Contenido de un archivo en el commit base del work tree, vía `got cat -c :base`. */
+/**
+ * Contenido de un archivo en el commit base del work tree, vía `got cat -c :base`.
+ *
+ * [revisionNumber] debe venir ya resuelto por quien construye esta instancia
+ * (fuera del EDT). getRevisionNumber() se llama desde el renderer del árbol
+ * de Commit y del título del diff, ambos en el hilo de UI: si esta clase
+ * ejecutara `got info` ahí mismo, IntelliJ lo reporta como "Synchronous
+ * execution on EDT" (ver OSProcessHandler#checkEdtAndReadAction).
+ */
class GotContentRevision(
private val filePath: FilePath,
private val workDir: File,
private val relativePath: String,
private val commandLine: GotCommandLineWrapper,
+ private val revisionNumber: VcsRevisionNumber,
) : ContentRevision {
@Throws(VcsException::class)
override fun getFile(): FilePath = filePath
- override fun getRevisionNumber(): VcsRevisionNumber = try {
- GotRevisionNumber(commandLine.baseCommit(workDir))
- } catch (e: VcsException) {
- VcsRevisionNumber.NULL
- }
+ override fun getRevisionNumber(): VcsRevisionNumber = revisionNumber
}
blob - 2e993f11cd12946885696846731a01e0c625bf13
blob + 1245cdbfb0ead63162a8a1aeec2554002161dee7
--- src/main/kotlin/dev/nezzontli/gotvcs/GotDiffProvider.kt
+++ src/main/kotlin/dev/nezzontli/gotvcs/GotDiffProvider.kt
override fun createFileContent(revisionNumber: VcsRevisionNumber, selectedFile: VirtualFile): ContentRevision? {
val (workDir, relativePath) = rootAndRelativePath(selectedFile) ?: return null
val filePath = VcsUtil.getFilePath(selectedFile)
- return GotContentRevision(filePath, workDir, relativePath, commandLine)
+ return GotContentRevision(filePath, workDir, relativePath, commandLine, revisionNumber)
}
override fun getLatestCommittedRevision(vcsRoot: VirtualFile): VcsRevisionNumber? =