File status tracking supported.
[?]
Mar 27, 2021, 4:35 PM
OPFG6CZ26PPTGTH7ULLRQGZGR3YEIEJOV5W2E3WN7PFRZS62CVLQCDependencies
Change contents
- edit in src/main/kotlin/com/github/jonathanxd/dracon/vfs/PijulVirtualFileStatusProvider.kt at line 3
import com.github.jonathanxd.dracon.pijul.SuccessStatusCodeimport com.github.jonathanxd.dracon.pijul.pijul - replacement in src/main/kotlin/com/github/jonathanxd/dracon/vfs/PijulVirtualFileStatusProvider.kt at line 12
TODO("Not yet implemented")val status = pijul(this.project).fileStatus(this.project, virtualFile)return if (status.statusCode is SuccessStatusCode) {status.result ?: FileStatus.UNKNOWN} else {FileStatus.UNKNOWN} - file deletion: PijulDiffJson.kt
package com.github.jonathanxd.dracon.pijulobject PijulDiffJson {fun parseJson() {}} - file addition: diff[3.3420]
- file addition: PijulDiffJson.kt[0.364]
package com.github.jonathanxd.dracon.pijul.diffimport com.google.gson.GsonBuilderimport com.google.gson.annotations.SerializedNameimport com.intellij.openapi.vcs.FileStatusimport kotlinx.coroutines.flow.Flowimport kotlinx.coroutines.flow.mapimport kotlin.reflect.javaTypeimport kotlin.reflect.typeOfobject PijulDiffJson {val GSON = GsonBuilder().disableHtmlEscaping().create()// TODO: Use Kotlin Flow and Flow-based Json reading@OptIn(ExperimentalStdlibApi::class)fun parseJson(json: String): List<ChangeEntry> =GSON.fromJson<Map<String, List<ChangeData>>>(json, typeOf<Map<String, List<ChangeData>>>().javaType).entries.map {ChangeEntry(it.key, it.value)}}fun List<ChangeEntry>.toFileStatusMap(): Map<String, List<FileStatus>> =this.associateBy { it.path }.mapValues {it.value.data.map { it.toFileStatus() }}fun ChangeData.toFileStatus(): FileStatus =when (this.operation) {"replacement", "edit" -> FileStatus.MODIFIED"file move" -> FileStatus.ADDED"file del" -> FileStatus.DELETED"file undel" -> FileStatus.ADDED"file add" -> FileStatus.ADDED// "solve name conflict" -> ?// "unsolve name conflict" -> ?// "solve order conflict" -> ?// "unsolve order conflict" -> ?// "resurrect zombies" -> ????????????????????else -> FileStatus.UNKNOWN}data class ChangeEntry(val path: String, val data: List<ChangeData>)data class ChangeData(@SerializedName("operation") val operation: String, @SerializedName("line") val line: Any?) - replacement in src/main/kotlin/com/github/jonathanxd/dracon/pijul/Pijul.kt at line 39
}fun findPijulDirectory(root: VirtualFile): VirtualFile? =findPijulDirectory(Paths.get(VcsUtil.getFilePath(root).path)) - replacement in src/main/kotlin/com/github/jonathanxd/dracon/pijul/Pijul.kt at line 43
fun findPijulDirectory(root: VirtualFile): VirtualFile? {var dir: Path? = Paths.get(VcsUtil.getFilePath(root).path)fun findPijulDirectory(root: Path): VirtualFile? {var dir: Path? = root - replacement in src/main/kotlin/com/github/jonathanxd/dracon/pijul/Pijul.kt at line 46
while (dir != null) {if (isPijulRepository(dir)) {return LocalFileSystem.getInstance().findFileByNioFile(dir)while (dir != null) {if (isPijulRepository(dir)) {return LocalFileSystem.getInstance().findFileByNioFile(dir)}dir = dir.parent - replacement in src/main/kotlin/com/github/jonathanxd/dracon/pijul/Pijul.kt at line 52
dir = dir.parentreturn null - replacement in src/main/kotlin/com/github/jonathanxd/dracon/pijul/Pijul.kt at line 56
return null}fun isUnderPijul(root: VirtualFile): Boolean = findPijulDirectory(root) != null - replacement in src/main/kotlin/com/github/jonathanxd/dracon/pijul/Pijul.kt at line 58
fun isUnderPijul(root: VirtualFile): Boolean = this.findPijulDirectory(root) != nullfun isUnderPijul(root: Path): Boolean = findPijulDirectory(root) != null} - edit in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 5
import com.github.jonathanxd.dracon.pijul.diff.PijulDiffJsonimport com.github.jonathanxd.dracon.pijul.diff.toFileStatusMap - edit in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 11
import com.intellij.openapi.components.Service - edit in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 14
import com.intellij.openapi.vcs.ProjectLevelVcsManager - edit in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 27
import kotlin.io.path.ExperimentalPathApiimport kotlin.io.path.relativeTo - edit in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 71
@OptIn(ExperimentalPathApi::class) - edit in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 74
val root = ProjectLevelVcsManager.getInstance(project).getVcsRootFor(file)?: return PijulOperationResult("file_status", SuccessStatusCode, FileStatus.UNKNOWN)val rootPath = Paths.get(VcsUtil.getFilePath(root).path)val execution = this.execPijul(project, rootPath, listOf("diff", "--json"), delay = 10L) - edit in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 80
return this.doExecutionWithMapper("file_status", execution) {val changes = PijulDiffJson.parseJson(it)val changeMap = changes.toFileStatusMap()val fPath = Paths.get(VcsUtil.getFilePath(file.path).path).relativeTo(rootPath).toString()if (fPath.isEmpty()) {FileStatus.SUPPRESSED} else {changeMap[fPath]?.firstOrNull()}} - edit in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 105
}}fun <T> doExecutionWithMapper(name: String,execution: PijulExecution,regularStreamStringMapper: (String) -> T?): PijulOperationResult<T> {val status = runBlocking(Dispatchers.IO) {execution.status.first() - edit in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 114
return if (status == 0) {val std = runBlocking(Dispatchers.IO) {execution.regularStream.toList().joinToString("\n")}PijulOperationResult(name, SuccessStatusCode, regularStreamStringMapper(std))} else {val error = runBlocking(Dispatchers.IO) {execution.errorStream.toList().joinToString("\n")}PijulOperationResult(name, NonZeroExitStatusCode(status, error), Unit) as PijulOperationResult<T>} - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 138
args: List<String>): PijulExecution {args: List<String>,delay: Long = 1000L): PijulExecution { - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 157
delay(1000L)delay(delay) - edit in src/main/kotlin/com/github/jonathanxd/dracon/actions/PijulInit.kt at line 5
import com.github.jonathanxd.dracon.pijul.Pijul - replacement in src/main/kotlin/com/github/jonathanxd/dracon/actions/PijulInit.kt at line 37
if (pijul(project).isUnderPijul(root)) {if (Pijul.isUnderPijul(root)) {