Fork channel

Create a new channel as a copy of main.

Rename channel

Rename main to:

Delete channel

Delete main? This cannot be undone.

PijulVcsFileRevision.kt
/**
 * Dracon - An IntelliJ-Pijul integration.
 * Copyright 2021 JonathanxD <jhrldev@gmail.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
package com.github.jonathanxd.dracon.revision

import com.github.jonathanxd.dracon.cache.FileRevisionCache
import com.intellij.openapi.components.service
import com.intellij.openapi.project.Project
import com.intellij.openapi.vcs.FilePath
import com.intellij.openapi.vcs.LocalFilePath
import com.intellij.openapi.vcs.RepositoryLocation
import com.intellij.openapi.vcs.history.VcsFileRevision
import com.intellij.openapi.vcs.history.VcsFileRevisionEx
import com.intellij.openapi.vcs.history.VcsRevisionNumber
import com.intellij.vcs.log.VcsUser
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import java.util.*
import kotlin.io.path.ExperimentalPathApi
import kotlin.io.path.relativeTo

class PijulVcsFileRevision constructor(val project: Project,
                           val vcsRoot: Path,
                           val filePath: Path,
                           val revision: PijulRevisionNumber,
                           val authors: List<VcsUser>,
                           val message: String?,
                           val branch: String?,
                           val deleted: Boolean) : VcsFileRevisionEx(), Comparable<PijulVcsFileRevision> {

    @OptIn(ExperimentalPathApi::class)
    constructor(project: Project,
                vcsRoot: Path,
                filePath: FilePath,
                revision: PijulRevisionNumber,
                authors: List<VcsUser>,
                message: String?,
                branch: String?,
                deleted: Boolean): this(project, vcsRoot, Paths.get(filePath.path).relativeTo(vcsRoot), revision, authors, message, branch, deleted)

    private val content by lazy {
        this.project.service<FileRevisionCache>().loadAsync(this)
    }

    override fun loadContent(): ByteArray = this.content.get()

    @Deprecated("Deprecated in Java", ReplaceWith("this.loadContent()"))
    override fun getContent(): ByteArray = this.loadContent()

    override fun getRevisionNumber(): VcsRevisionNumber = this.revision

    override fun getRevisionDate(): Date = Date.from(this.revision.timestamp.toInstant())

    override fun getAuthor(): String? = this.authors.map { it.name }.firstOrNull()

    override fun getCommitMessage(): String? = this.message

    override fun getBranchName(): String? = this.branch

    override fun getChangedRepositoryPath(): RepositoryLocation? = null

    override fun getAuthorEmail(): String? =
        this.authors.map { it.email }.firstOrNull()

    override fun getCommitterName(): String? = this.author

    override fun getCommitterEmail(): String? = this.authorEmail

    override fun getPath(): FilePath =
        LocalFilePath(this.filePath, Files.isDirectory(this.filePath))

    override fun getAuthorDate(): Date? = Date.from(this.revision.timestamp.toInstant())

    override fun isDeleted(): Boolean = this.deleted

    override fun compareTo(other: PijulVcsFileRevision): Int =
        this.revision.timestamp.compareTo(other.revision.timestamp)


}