Initial CahngeProvider

[?]
Mar 29, 2021, 1:50 AM
QXUEMZ3B2FUHFUC7ZZHJMH5FVWLEMEYXUMFA6JNXTJKIVZNMRIOAC

Dependencies

  • [2] PGNTR2EP Improved README and ider roadmap
  • [3] NTRPUMVQ Improved README and added roadmap.
  • [*] FNNW5IEA Added more plugin files to Pijul
  • [*] OPFG6CZ2 File status tracking supported.
  • [*] GGYFPXND Initial plugin

Change contents

  • file addition: revision (d--r------)
    [5.107]
  • file addition: PijulRevisionNumber.kt (----------)
    [0.11]
    package com.github.jonathanxd.dracon.revision
    import com.intellij.openapi.vcs.changes.patch.BlobIndexUtil
    import com.intellij.openapi.vcs.history.ShortVcsRevisionNumber
    import com.intellij.openapi.vcs.history.VcsRevisionNumber
    import java.time.LocalDateTime
    import java.time.ZonedDateTime
    class PijulRevisionNumber(val hash: String, val timestamp: ZonedDateTime) : ShortVcsRevisionNumber {
    val NOT_COMMITTED_HASH = BlobIndexUtil.NOT_COMMITTED_HASH
    override fun compareTo(other: VcsRevisionNumber): Int {
    if (this === other) return 0
    if (other is PijulRevisionNumber) {
    return this.timestamp.compareTo(other.timestamp)
    }
    return -1
    }
    override fun asString(): String = this.hash
    override fun toShortString(): String = this.asString()
    }
  • file addition: provider (d--r------)
    [5.107]
  • file addition: PijulChangeProvider.kt (----------)
    [0.854]
    package com.github.jonathanxd.dracon.provider
    import com.intellij.openapi.progress.ProgressIndicator
    import com.intellij.openapi.project.Project
    import com.intellij.openapi.vcs.VcsKey
    import com.intellij.openapi.vcs.changes.*
    class PijulChangeProvider(val project: Project, val key: VcsKey) : ChangeProvider {
    override fun getChanges(
    dirtyScope: VcsDirtyScope,
    builder: ChangelistBuilder,
    progress: ProgressIndicator,
    addGate: ChangeListManagerGate
    ) {
    if (project.isDisposed) return
    val dirtDirs = dirtyScope.recursivelyDirtyDirectories
    println(dirtDirs)
    }
    override fun isModifiedDocumentTrackingRequired(): Boolean = true
    }
  • edit in src/main/kotlin/com/github/jonathanxd/dracon/pijul/Pijul.kt at line 13
    [5.4473]
    [5.4473]
    import com.github.jonathanxd.dracon.log.PijulLog
    import com.github.jonathanxd.dracon.revision.PijulRevisionNumber
  • edit in src/main/kotlin/com/github/jonathanxd/dracon/pijul/Pijul.kt at line 82
    [5.6839]
    [5.6839]
    @RequiresBackgroundThread
    fun latestRevisionNumber(project: Project, root: VirtualFile): PijulOperationResult<PijulRevisionNumber>
    @RequiresBackgroundThread
    fun log(project: Project, root: VirtualFile): PijulOperationResult<PijulLog>
  • file addition: PijulLog.kt (----------)
    [5.6847]
    package com.github.jonathanxd.dracon.log
    import java.time.LocalDateTime
    import java.time.ZonedDateTime
    import java.time.format.DateTimeFormatter
    import java.time.format.ResolverStyle
    class Author(val name: String?, val fullName: String?, val email: String?)
    class PijulLog(val entries: List<PijulLogEntry>)
    class PijulLogEntry(
    val changeHash: String,
    val message: String,
    val date: ZonedDateTime,
    val authors: List<Author>
    )
    val MESSAGE_PATTERN = Regex("message = '(.*)'\\n")
    val TIME_PATTERN = Regex("timestamp = '(.*)'\\n")
    val AUTHORS_SECTION_PATTERN = Regex("\\[\\[authors\\]\\]\n")
    val AUTHOR_PATTERN = Regex("name = '(.*)'\\n")
    fun String.parseChange(hash: String): PijulLogEntry {
    val message = MESSAGE_PATTERN.find(this)?.groupValues?.get(1)!!
    val timestamp = TIME_PATTERN.find(this)?.groupValues?.get(1)!!
    val authorsSection = AUTHORS_SECTION_PATTERN.find(this)?.range?.endInclusive
    val authors = mutableListOf<Author>()
    if (authorsSection != null) {
    var lastFound: Int? = authorsSection
    while (lastFound != null) {
    val foundAuthor = AUTHOR_PATTERN.find(this, lastFound)
    val foundAuthorGroup = foundAuthor?.groupValues?.get(1)
    if (foundAuthorGroup != null) {
    authors += Author(foundAuthorGroup, null, null)
    lastFound = if (foundAuthor.range.last + 1 < this.length && this[foundAuthor.range.last + 1] == '\n') {
    null
    } else {
    foundAuthor.range.last
    }
    } else {
    lastFound = null
    }
    }
    }
    return PijulLogEntry(hash, message, timestamp.parseAsLocalDateTime(), authors)
    }
    val RFC3339_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss[.SSSSSSSSS]XXX")
    .withResolverStyle(ResolverStyle.LENIENT)
    fun String.parseAsLocalDateTime(): ZonedDateTime {
    return ZonedDateTime.parse(this, RFC3339_FORMATTER)
    }
  • edit in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 13
    [5.11015]
    [5.11015]
    import com.github.jonathanxd.dracon.log.PijulLog
    import com.github.jonathanxd.dracon.log.PijulLogEntry
  • edit in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 16
    [5.11075]
    [5.11075]
    import com.github.jonathanxd.dracon.log.parseChange
  • edit in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 20
    [6.2779]
    [5.11119]
    import com.github.jonathanxd.dracon.revision.PijulRevisionNumber
  • edit in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 106
    [5.13610]
    [5.13610]
    override fun log(project: Project, root: VirtualFile): PijulOperationResult<PijulLog> {
    val rootPath = Paths.get(VcsUtil.getFilePath(root).path)
    val logHashExecution = this.execPijul(project, rootPath, listOf("log", "--hash-only"), delay = 10L)
  • edit in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 112
    [5.13611]
    [5.13611]
    val hashes = this.doExecutionWithMapper("log--hash-only", logHashExecution) {
    it.lines()
    }
    if (hashes.statusCode !is SuccessStatusCode) {
    return hashes as PijulOperationResult<PijulLog>
    } else {
    val entries = mutableListOf<PijulLogEntry>()
    for (hash in hashes.result!!) {
    val change = this.doExecutionWithMapper("change-$hash", this.execPijul(project, rootPath, listOf("change", hash), delay = 10L)) {
    it.parseChange(hash)
    }
    if (change.statusCode !is SuccessStatusCode) {
    return change as PijulOperationResult<PijulLog>
    }
    }
    return PijulOperationResult(hashes.operation, hashes.statusCode, PijulLog(entries))
    }
    }
    override fun latestRevisionNumber(project: Project, root: VirtualFile): PijulOperationResult<PijulRevisionNumber> {
    /*val root = ProjectLevelVcsManager.getInstance(project).getVcsRootFor(file)
    ?: return PijulOperationResult("file_status", SuccessStatusCode, FileStatus.UNKNOWN)*/
    val rootPath = Paths.get(VcsUtil.getFilePath(root).path)
    val log = this.log(project, root)
    return PijulOperationResult(log.operation, log.statusCode,
    log.result?.entries?.firstOrNull()?.let {
    PijulRevisionNumber(it.changeHash, it.date)
    }
    )
    }
  • edit in src/main/kotlin/com/github/jonathanxd/dracon/PijulVcs.kt at line 14
    [5.24239]
    [5.24239]
    import com.github.jonathanxd.dracon.provider.PijulChangeProvider
  • edit in src/main/kotlin/com/github/jonathanxd/dracon/PijulVcs.kt at line 20
    [5.24475]
    [5.24475]
    import com.intellij.openapi.vcs.changes.ChangeProvider
  • edit in src/main/kotlin/com/github/jonathanxd/dracon/PijulVcs.kt at line 46
    [5.25153]
    [5.25153]
    override fun getChangeProvider(): ChangeProvider =
    PijulChangeProvider(this.project, KEY)
  • file addition: dada.toml (----------)
    [1.0]
  • edit in build.gradle.kts at line 33
    [7.14803]
    [7.14803]
    maven(url = "https://jitpack.io")
  • edit in build.gradle.kts at line 36
    [7.14820]
    [7.14820]
    implementation("org.tomlj:tomlj:1.0.0")
    implementation("com.github.JonathanxD.JwIUtils:JwIUtils:4.17.0") {
    exclude(group = "org.jetbrains")
    }
  • replacement in README.md at line 21
    [2.59651][2.59651:59660]()
    - [ ] ...
    [2.59651]
    - [ ] ...
    # FAQ
    ## Why Dracon and not Pijul for IDEA (or something like that)?
    Because Dracon is not an official plugin, and I want to make sure that it is clear to anyone who uses this plugin. Dracon is an individual project being developed by [Jonathan H. R. Lopes](https://github.com/JonathanxD) which does not have any relation with Pijul creator. Also, Dracon uses MIT license, allowing to anyone, and that includes the Pijul creator, to contribute and create your own version of Dracon, if wish to.
    ## Why Dracon is developed against IntelliJ EAP instead of a stable releases?
    Dracon is being developed based in actual [HG4Idea](https://github.com/JetBrains/intellij-community/tree/master/plugins/hg4idea) and [Git4Idea](https://github.com/JetBrains/intellij-community/tree/master/plugins/git4idea) plugins, as well based in current code of [IntelliJ IDEA Community](https://github.com/JetBrains/intellij-community/), and is planned to be released by the end of first semester of 2021, when release time comes, the IntelliJ EAP will be already released as stable, also I don't want to support older releases of IntelliJ IDEA because this involves basing on deprecated code, and this is my first IDEA plugin, so the more I focus the present than the past, more I deliver in terms of better and stable features.
    ## Could I contribute to Dracon development?
    I'm currently focused on learning how IDEA Plugin platform works and how DVCS is implemented in IDEA, so until Dracon is officially released, I will not be accepting contributions, but Dracon is licensed under MIT, you are free to create your own version of Dracon and developing it on your own.
    ## When Dracon will be official released?
    I will be periodically releasing Dragon experimental builds, but Dracon stable release is planned by the end of first semester of 2021.