Commit Diff


commit - ba7062dfbcc4fbe591ab7ce9766e2e1a09a837a8
commit + b462f47784c7203ab8c1953668f7f02818d9d4f8
blob - aa3ca7d9f9e8d1e61942a98c450ac8363ad603ca
blob + 494b3a993df8f194bef0aa5676fcf7ab47891285
--- src/main/kotlin/dev/nezzontli/gotvcs/GotChangeProvider.kt
+++ src/main/kotlin/dev/nezzontli/gotvcs/GotChangeProvider.kt
@@ -8,7 +8,9 @@ import com.intellij.openapi.vcs.changes.ChangeProvider
 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
@@ -24,7 +26,16 @@ class GotChangeProvider(private val commandLine: GotCo
         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)
@@ -36,7 +47,7 @@ class GotChangeProvider(private val commandLine: GotCo
 
                     '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())
                     }
@@ -47,7 +58,7 @@ class GotChangeProvider(private val commandLine: GotCo
                     }
 
                     '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
@@ -6,12 +6,21 @@ import com.intellij.openapi.vcs.changes.ContentRevisio
 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)
@@ -19,9 +28,5 @@ class GotContentRevision(
 
     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
@@ -55,7 +55,7 @@ class GotDiffProvider(
     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? =