Fork channel

Create a new channel as a copy of main.

Rename channel

Rename main to:

Delete channel

Delete main? This cannot be undone.

PijulVcs.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

import com.github.jonathanxd.dracon.changes.PijulCommittedChangesProvider
import com.github.jonathanxd.dracon.checkin.PijulCheckingEnvironment
import com.github.jonathanxd.dracon.i18n.DraconBundle
import com.github.jonathanxd.dracon.listeners.PijulAsyncFileListener
import com.github.jonathanxd.dracon.provider.PijulChangeProvider
import com.github.jonathanxd.dracon.provider.PijulDiffProvider
import com.github.jonathanxd.dracon.provider.PijulHistoryProvider
import com.intellij.openapi.Disposable
import com.intellij.openapi.components.service
import com.intellij.openapi.progress.ProgressManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.vcs.AbstractVcs
import com.intellij.openapi.vcs.CommittedChangesProvider
import com.intellij.openapi.vcs.ProjectLevelVcsManager
import com.intellij.openapi.vcs.VcsType
import com.intellij.openapi.vcs.changes.ChangeProvider
import com.intellij.openapi.vcs.checkin.CheckinEnvironment
import com.intellij.openapi.vcs.diff.DiffProvider
import com.intellij.openapi.vcs.history.VcsHistoryProvider
import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.vfs.VirtualFileManager


const val NAME = "Pijul"
const val ID = "pijul"
val DISPLAY_NAME_SUPPLIER = DraconBundle.Dracon.nameSupplier

fun pijulVcs(project: Project): PijulVcs {
    val vcs = ProjectLevelVcsManager.getInstance(project).findVcsByName(NAME) as PijulVcs
    ProgressManager.checkCanceled()
    return vcs
}

class PijulVcs(project: Project) : AbstractVcs(project, NAME) {

    override fun activate() {
        super.activate()
    }

    override fun getDisplayName(): String =
        DISPLAY_NAME_SUPPLIER.get()

    override fun getType(): VcsType =
        VcsType.distributed

    @Deprecated("Deprecated in Java",
        ReplaceWith("super.isVersionedDirectory(dir)", "com.intellij.openapi.vcs.AbstractVcs")
    )
    override fun isVersionedDirectory(dir: VirtualFile?): Boolean {
        return super.isVersionedDirectory(dir)
    }

    override fun getChangeProvider(): ChangeProvider =
        PijulChangeProvider(this.project, KEY)

    override fun getVcsHistoryProvider(): VcsHistoryProvider =
        project.service<PijulHistoryProvider>()

    override fun getVcsBlockHistoryProvider(): VcsHistoryProvider =
        this.vcsHistoryProvider

    override fun getDiffProvider(): DiffProvider =
        project.service<PijulDiffProvider>()

    override fun getShortNameWithMnemonic(): String =
        DraconBundle.Dracon.mnemonic

    override fun getCheckinEnvironment(): CheckinEnvironment =
        project.service<PijulCheckingEnvironment>()

    override fun getCommittedChangesProvider(): CommittedChangesProvider<out CommittedChangeList, *>? =
        project.service<PijulCommittedChangesProvider>()

    companion object {
        val KEY = createKey(NAME)
    }
}