QXUEMZ3B2FUHFUC7ZZHJMH5FVWLEMEYXUMFA6JNXTJKIVZNMRIOAC package com.github.jonathanxd.dracon.revisionimport com.intellij.openapi.vcs.changes.patch.BlobIndexUtilimport com.intellij.openapi.vcs.history.ShortVcsRevisionNumberimport com.intellij.openapi.vcs.history.VcsRevisionNumberimport java.time.LocalDateTimeimport java.time.ZonedDateTimeclass PijulRevisionNumber(val hash: String, val timestamp: ZonedDateTime) : ShortVcsRevisionNumber {val NOT_COMMITTED_HASH = BlobIndexUtil.NOT_COMMITTED_HASHoverride fun compareTo(other: VcsRevisionNumber): Int {if (this === other) return 0if (other is PijulRevisionNumber) {return this.timestamp.compareTo(other.timestamp)}return -1}override fun asString(): String = this.hashoverride fun toShortString(): String = this.asString()}
package com.github.jonathanxd.dracon.providerimport com.intellij.openapi.progress.ProgressIndicatorimport com.intellij.openapi.project.Projectimport com.intellij.openapi.vcs.VcsKeyimport 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) returnval dirtDirs = dirtyScope.recursivelyDirtyDirectoriesprintln(dirtDirs)}override fun isModifiedDocumentTrackingRequired(): Boolean = true}
package com.github.jonathanxd.dracon.logimport java.time.LocalDateTimeimport java.time.ZonedDateTimeimport java.time.format.DateTimeFormatterimport java.time.format.ResolverStyleclass 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?.endInclusiveval authors = mutableListOf<Author>()if (authorsSection != null) {var lastFound: Int? = authorsSectionwhile (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)}
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)})}
- [ ] ...
- [ ] ...# 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.