DLDMHQY6F53N2YXNDBQY77GAU2I4N2OWC3DL6L36T2SSAVW6YSXAC RE4EKNSLYGCITZZEOPIRJAWTKIONGP7IY6S77BQO7JQL2CK27RZAC 37OJKSWJFDRHNWQW6P7HSZX6OWZWVNCJ2IFT42O5TANQF7VOVX6AC OMZXJL6QA6INENIEAARSWYFHOPMLTP4WRCVI646GQVJVWCH3LENQC GGYFPXND4VBCROZZXTKAP7Y4JOP2OOYQAFVLMUE7SLFM225EUSIAC ZCRW57C5MSBXYGUMGQTZNHGHO4HGHFBICW53X5I2IMGP3H2CKWRQC FNNW5IEAXQ43WKB6QSQB7DFLG3Y3T5FYPXIUX7KQ2URR2GU3QLTAC Q7FXTHVUPVAFMNY277C3NFJO3VXLZU5G6C6UYSD5QPURHSG3A7OQC FRFFQV7VNYKGCA7ZAOSRPC2HHYTAIZ6AGGR7A5QEV6QPAQGFDYGAC B43WNBLFFR2UQIH3C6KIZAQTAEQOQM3J3IYLGQMVGJHYOME73OKQC OPFG6CZ26PPTGTH7ULLRQGZGR3YEIEJOV5W2E3WN7PFRZS62CVLQC ISO7J5ZH5UB7NFZKTKKJQHQHCP4DWQ3F7SM2NDMVYJAGGIKDLX4QC 2N67RQZCVGL6GYJJLM2US4YVCEIUK25AHCLD66C7HR4PPTNUOCWAC MZYZIVHY5DUHVJH7YGENRAIKTKMZWJ5ANRVGFLLU7YTHXC2OXZJQC remote.invalid.remote.text=Invalid remote server {0}...
settings.title=Dracon (Pijul)settings.pijul.path.text=Pijul path:settings.pijul.path.detect.text=Detectsettings.pijul.path.select.text=Select Pijul Binarysettings.dracon.index.all.text=Index all revisionssettings.dracon.index.all.tooltip.text=Enable caching of all revisions, it does speed up revision loading however \caching uses a bunch of storage space and takes a bit of more time at first loading.
package com.github.jonathanxd.dracon.execimport com.github.jonathanxd.dracon.i18n.BUNDLEimport com.github.jonathanxd.dracon.i18n.DraconBundleimport com.intellij.execution.configurations.GeneralCommandLineimport com.intellij.execution.process.ProcessOutputimport com.intellij.execution.util.ExecUtilimport org.jetbrains.annotations.PropertyKeyimport java.nio.file.Pathfun execInTerminal(@PropertyKey(resourceBundle = BUNDLE) name: String,command: String) {ExecUtil.execAndGetOutput(GeneralCommandLine(ExecUtil.getTerminalCommand(DraconBundle.message(name), command)))}fun execInTerminal(@PropertyKey(resourceBundle = BUNDLE) name: String,vars: Map<String, String>,workDir: Path,command: String): ProcessOutput {val cmd = GeneralCommandLine(ExecUtil.getTerminalCommand(DraconBundle.message(name), command))cmd.environment.putAll(vars)cmd.workDirectory = workDir.toFile()return ExecUtil.execAndGetOutput(cmd)}fun terminalCommand(@PropertyKey(resourceBundle = BUNDLE) name: String,command: String): List<String> {return ExecUtil.getTerminalCommand(DraconBundle.message(name), command)}
package com.github.jonathanxd.dracon.componentimport com.github.jonathanxd.dracon.config.PijulSettingsimport com.github.jonathanxd.dracon.i18n.DraconBundleimport com.intellij.openapi.options.Configurableimport javax.swing.JComponentclass PijulSettingsConfigurable: Configurable {private var pijulSettingsComponent: PijulSettingsComponent? = nulloverride fun createComponent(): JComponent =PijulSettingsComponent().let {this.pijulSettingsComponent = itit}.mainPaneloverride fun getPreferredFocusedComponent(): JComponent? =this.pijulSettingsComponent?.preferredFocusedComponentoverride fun isModified(): Boolean {val settings = PijulSettings.instanceval pathToPijul = settings.getPathToPijul()val cacheAllRevisions = settings.isToCacheAllRevisions()var modified = this.pijulSettingsComponent?.pijulPath?.text != pathToPijulmodified = modified || (this.pijulSettingsComponent?.indexAllRevisions?.isSelected == cacheAllRevisions)return modified}override fun apply() {val settings = PijulSettings.instancesettings.savePathToPijul(this.pijulSettingsComponent?.pijulPath?.text)settings.saveToCacheAllRevisions(this.pijulSettingsComponent?.indexAllRevisions?.isSelected ?: false)}override fun getDisplayName(): String =DraconBundle.message("settings.title")override fun reset() {val settings = PijulSettings.instancethis.pijulSettingsComponent?.pijulPath?.text = settings.getPathToPijul() ?: ""this.pijulSettingsComponent?.indexAllRevisions?.isSelected = settings.isToCacheAllRevisions()}override fun disposeUIResources() {this.pijulSettingsComponent = null}}
package com.github.jonathanxd.dracon.componentimport com.github.jonathanxd.dracon.i18n.DraconBundleimport com.github.jonathanxd.dracon.util.findBinaryOrNullimport com.intellij.openapi.fileChooser.FileChooserDescriptorimport com.intellij.openapi.fileTypes.FileTypeRegistryimport com.intellij.openapi.ui.FixedSizeButtonimport com.intellij.openapi.ui.TextFieldWithBrowseButtonimport com.intellij.openapi.vfs.VirtualFileimport com.intellij.ui.components.JBCheckBoximport com.intellij.ui.components.JBLabelimport com.intellij.uiDesigner.core.Spacerimport com.intellij.util.ui.FormBuilderimport com.intellij.util.ui.UIUtilimport java.awt.BorderLayoutimport java.awt.event.MouseAdapterimport java.awt.event.MouseEventimport javax.swing.JButtonimport javax.swing.JComponentimport javax.swing.JPanelclass PijulSettingsComponent {val indexAllRevisions = JBCheckBox(DraconBundle.message("settings.dracon.index.all.text")).also {it.toolTipText = DraconBundle.message("settings.dracon.index.all.tooltip.text")}val pijulPath = TextFieldWithBrowseButton().also {it.addBrowseFolderListener(DraconBundle.message("settings.pijul.path.select.text"),"",null,FileChooserDescriptor(true, false, false, false, false, false).withFileFilter { file: VirtualFile? ->file?.name == "pijul"})}val detectPijul = JButton(DraconBundle.message("settings.pijul.path.detect.text")).also {it.addMouseListener(object : MouseAdapter() {override fun mouseClicked(e: MouseEvent) {pijulPath.text = findBinaryOrNull("pijul") ?: ""}})it.updateUI()}var mainPanel: JPanel =FormBuilder.createFormBuilder().addLabeledComponent(JBLabel(DraconBundle.message("settings.pijul.path.text")), pijulPath, 1, false).addComponent(JPanel(BorderLayout()).also {it.add(indexAllRevisions, BorderLayout.WEST)it.add(detectPijul, BorderLayout.EAST)}, 0).addComponentFillVertically(JPanel(), 0).panelval preferredFocusedComponent: JComponentget() = this.pijulPath}
this.project,root,arguments,editorServerConsumer)return this.doExecutionWithMapper("push", operation) {it}}override fun pushInTerminal(project: Project,root: Path,fromChannel: String?,toChannel: String?,repository: String?,editorServerConsumer: (EditorServer) -> Unit): PijulOperationResult<String> {val arguments = mutableListOf("push")if (fromChannel != null) {arguments.add("--from-channel")arguments.add(fromChannel)}if (toChannel != null) {arguments.add("--to-channel")arguments.add(toChannel)}if (repository != null) {arguments.add(repository)}val operation = this.createPainlessExecPijulWithEditorServerInTerminal(
.directory(dir.toFile()).start()editorServerConsumer(EditorServer(freePort) {!process.isAlive})val input = String(process.inputStream.readAllBytes(), Charsets.UTF_8)val error = String(process.errorStream.readAllBytes(), Charsets.UTF_8)input.split("\n").forEach {draconConsoleWriter(project).logCommand("pijul", args, it)}error.split("\n").forEach {draconConsoleWriter(project).logCommandError("pijul", args, it)}val exit = process.waitFor()if (exit == 0) {draconConsoleWriter(project).logCommand("pijul", args, "<Exit status> $exit")} else {draconConsoleWriter(project).logCommandError("pijul", args, "<Exit status> $exit")}return PijulExecution(input,error,exit)}/*** Creates a [PijulExecution] operation that could be executed at any time. This operation uses Kotlin Coroutines* and can be executed immediately through [doExecution] or through [doExecutionWithMapper].** This implementation does not requires a delay value to be provided, like [createExecPijulOperation] does, instead* it uses the kotlin conversion from `CompletionStage` to `Coroutines` and awaits the process through [Process.onExit].** [doExecution] and [doExecutionWithMapper] does execution by scheduling task to [Dispatchers.IO], instead of Main Thread,* offloading the Process execution handling to a different scheduler. However, mapping operation of [doExecutionWithMapper]* is not offloaded from the caller context.**/@RequiresBackgroundThreadprivate fun createPainlessExecPijulWithEditorServerInTerminal(project: Project,dir: Path,args: List<String>,editorServerConsumer: (EditorServer) -> Unit): PijulExecution {val freePort = freePort()val cmd = listOf(this.findPijul()) + argsval terminalCmd = terminalCommand("command.execute.text", cmd.joinToString(" "))val process = ProcessBuilder().apply {environment()["EDITOR_SERVER_PORT"] = freePort.toString()environment()["VISUAL"] = editorServerPath()environment()["EDITOR"] = editorServerPath()}.command(terminalCmd)