Add support to view files affected by a revision
[?]
Apr 1, 2021, 12:07 AM
5AUENX2YJVFNKZUSPEPDNLLL7TKZS2WTFC6CABWSZK2EC4MNCRQACDependencies
- [2]
ZCRW57C5Improved support for revisions - [3]
FRFFQV7VBasic show history support. - [4]
7L5LODGZParse changes from `pijul change` - [5]
6CR2EFUNFirst ChangeProvider implementation!!! Wheehooo - [6]
QXUEMZ3BInitial CahngeProvider - [7]
Q7FXTHVUFirst record support, YEAAAH, RECOOORD - [*]
FNNW5IEAAdded more plugin files to Pijul - [*]
OPFG6CZ2File status tracking supported.
Change contents
- replacement in src/main/kotlin/com/github/jonathanxd/dracon/revision/PijulVcsFileRevision.kt at line 25
val deleted: Boolean) : VcsFileRevisionEx(), Comparable<PijulVcsFileRevision> {val deleted: Boolean) : VcsFileRevisionEx(), Comparable<PijulVcsFileRevision> { - edit in src/main/kotlin/com/github/jonathanxd/dracon/provider/PijulHistoryProvider.kt at line 3
import com.github.jonathanxd.dracon.context.PijulVcsContext - edit in src/main/kotlin/com/github/jonathanxd/dracon/provider/PijulHistoryProvider.kt at line 11
import com.intellij.openapi.actionSystem.ActionManager - edit in src/main/kotlin/com/github/jonathanxd/dracon/provider/PijulHistoryProvider.kt at line 14
import com.intellij.openapi.components.service - edit in src/main/kotlin/com/github/jonathanxd/dracon/provider/PijulHistoryProvider.kt at line 18
import com.intellij.openapi.vcs.VcsActions - edit in src/main/kotlin/com/github/jonathanxd/dracon/provider/PijulHistoryProvider.kt at line 20
import com.intellij.openapi.vcs.annotate.ShowAllAffectedGenericAction - edit in src/main/kotlin/com/github/jonathanxd/dracon/provider/PijulHistoryProvider.kt at line 24
import com.intellij.vcs.history.VcsHistoryProviderEx - edit in src/main/kotlin/com/github/jonathanxd/dracon/provider/PijulHistoryProvider.kt at line 26
import java.nio.file.Paths - replacement in src/main/kotlin/com/github/jonathanxd/dracon/provider/PijulHistoryProvider.kt at line 30
class PijulHistoryProvider(val project: Project) : VcsHistoryProvider {class PijulHistoryProvider(val project: Project) : VcsHistoryProvider,VcsHistoryProviderEx { - replacement in src/main/kotlin/com/github/jonathanxd/dracon/provider/PijulHistoryProvider.kt at line 41
return emptyArray()return arrayOf(ShowAllAffectedGenericAction.getInstance(),ActionManager.getInstance().getAction(VcsActions.ACTION_COPY_REVISION_NUMBER)) - edit in src/main/kotlin/com/github/jonathanxd/dracon/provider/PijulHistoryProvider.kt at line 82
override fun reportAppendableHistory(path: FilePath,startingRevision: VcsRevisionNumber?,partner: VcsAppendableHistorySessionPartner) {reportAppendableHistory(path, partner)}override fun getLastRevision(filePath: FilePath): VcsFileRevision? {val ctx = this.project.service<PijulVcsContext>()val root = ctx.rootval revisions = pijul(project).revisions(this.project, root, ctx.resolveUnderVcs(filePath))return revisions.result?.firstOrNull()} - edit in src/main/kotlin/com/github/jonathanxd/dracon/provider/PijulHistoryProvider.kt at line 112
// TODO: Should we limit to show only one revision when introspecting directories instead of all revisions? - edit in src/main/kotlin/com/github/jonathanxd/dracon/pijul/Pijul.kt at line 17
import com.github.jonathanxd.dracon.revision.PijulVcsFileRevision - edit in src/main/kotlin/com/github/jonathanxd/dracon/pijul/Pijul.kt at line 106
fun revisions(project: Project, root: Path, file: Path): PijulOperationResult<List<PijulVcsFileRevision>>fun allRevisions(project: Project, root: Path): PijulOperationResult<List<PijulRevisionNumber>> - edit in src/main/kotlin/com/github/jonathanxd/dracon/pijul/Pijul.kt at line 118
* Retrieves info about pijul channels.*/@RequiresBackgroundThreadfun channel(project: Project, root: Path): PijulOperationResult<ChannelInfo>/** - edit in src/main/kotlin/com/github/jonathanxd/dracon/pijul/Pijul.kt at line 146
* Retrieves change history*/@RequiresBackgroundThreadfun fileHistory(project: Project,root: Path,file: Path,consumer: (PijulLogEntry) -> Unit,errorConsumer: (PijulOperationResult<Unit>) -> Unit): PijulOperationResult<Unit>/** - edit in src/main/kotlin/com/github/jonathanxd/dracon/log/PijulLog.kt at line 3
import com.github.jonathanxd.dracon.revision.PijulRevisionNumberimport com.intellij.openapi.vcs.FileStatus - edit in src/main/kotlin/com/github/jonathanxd/dracon/log/PijulLog.kt at line 24
val PijulLogEntry.revision: PijulRevisionNumber get() = PijulRevisionNumber(this.changeHash, this.date) - replacement in src/main/kotlin/com/github/jonathanxd/dracon/log/PijulLog.kt at line 910
")"[3.90451]")"val HunkWithPath.status: FileStatusget() = (this as Hunk).statusval Hunk.status: FileStatusget() = when(this) {is FileAddHunk -> FileStatus.ADDEDis FileDelHunk -> FileStatus.DELETEDis ReplacementHunk -> FileStatus.MODIFIEDis EditHunk -> FileStatus.MODIFIEDis MoveHunk -> FileStatus.SUPPRESSEDelse -> FileStatus.UNKNOWN} - file addition: dialog[9.107]
- file addition: PijulExpertRecordDialogV2.kt[0.2837]
package com.github.jonathanxd.dracon.dialogimport com.github.jonathanxd.dracon.i18n.DraconBundleimport com.intellij.openapi.application.ApplicationManagerimport com.intellij.openapi.fileTypes.FileTypeRegistryimport com.intellij.openapi.project.Projectimport com.intellij.openapi.ui.DialogPanelimport com.intellij.openapi.ui.DialogWrapperimport com.intellij.openapi.ui.DialogWrapper.IdeModalityTypeimport com.intellij.openapi.wm.WindowManagerimport com.intellij.ui.EditorTextFieldimport com.intellij.ui.layout.panelimport org.jetbrains.annotations.Nullableimport java.awt.Componentimport java.awt.Windowimport java.awt.event.ComponentAdapterimport java.awt.event.ComponentEventimport javax.swing.JComponentimport java.awt.BorderLayoutimport java.awt.Dimensionimport javax.swing.JLabelimport javax.swing.JPanelfun createPijulRecordDialog(project: Project, text: String): DialogPanel {val panel = panel {}val toml = FileTypeRegistry.getInstance().getFileTypeByExtension("toml")val editor = EditorTextField(text, project, toml)editor.preferredSize = Dimension(340, 460)panel.add(editor)return panel}class PijulExpertRecordDialogV2(val project: Project, val text: String) : DialogWrapper(project, true) {/*constructor(project: Project?, canBeParent: Boolean): super(project, canBeParent)constructor(project: Project?, canBeParent: Boolean, ideModalityType: IdeModalityType): super(project, canBeParent, ideModalityType)constructor(project: Project?,parentComponent: Component?,canBeParent: Boolean,ideModalityType: IdeModalityType): super (project, parentComponent, canBeParent, ideModalityType, true)constructor(project: Project?,parentComponent: Component?,canBeParent: Boolean,ideModalityType: IdeModalityType,createSouth: Boolean) : super(project, parentComponent, canBeParent, ideModalityType, createSouth)constructor(project: Project?): super(project)constructor(canBeParent: Boolean): super(canBeParent)constructor(canBeParent: Boolean, applicationModalIfPossible: Boolean): super(null, canBeParent, applicationModalIfPossible)constructor(project: Project?, canBeParent: Boolean, applicationModalIfPossible: Boolean): super(project, canBeParent, applicationModalIfPossible)constructor(parent: Component, canBeParent: Boolean): super(parent, canBeParent)*/init {init()title = DraconBundle.message("action.Pijul.ExpertRecord.text")}override fun createCenterPanel(): JComponent {val dialogPanel = JPanel(BorderLayout())val toml = FileTypeRegistry.getInstance().getFileTypeByExtension("toml")val editor = EditorTextField(this.text, this.project, toml)editor.preferredSize = Dimension(340, 460)dialogPanel.add(editor, BorderLayout.CENTER)return dialogPanel}} - file addition: PijulExpertRecordDialog.kt[0.2837]
package com.github.jonathanxd.dracon.dialogimport com.github.jonathanxd.dracon.completion.PijulRecordFileTextCompletionProviderimport com.github.jonathanxd.dracon.i18n.DraconBundleimport com.github.jonathanxd.dracon.pijul.NonZeroExitStatusCodeimport com.github.jonathanxd.dracon.pijul.SuccessStatusCodeimport com.github.jonathanxd.dracon.pijul.pijulimport com.intellij.CommonBundleimport com.intellij.ide.IdeBundleimport com.intellij.lang.Languageimport com.intellij.notification.Notificationimport com.intellij.notification.NotificationGroupimport com.intellij.notification.NotificationTypeimport com.intellij.notification.Notificationsimport com.intellij.openapi.application.ApplicationManagerimport com.intellij.openapi.editor.Documentimport com.intellij.openapi.editor.ex.EditorEximport com.intellij.openapi.fileTypes.FileTypeRegistryimport com.intellij.openapi.project.Projectimport com.intellij.openapi.ui.DialogEarthquakeShakerimport com.intellij.openapi.ui.DialogWrapperimport com.intellij.openapi.ui.DialogWrapper.DialogWrapperActionimport com.intellij.openapi.ui.DialogWrapper.IdeModalityTypeimport com.intellij.openapi.ui.ValidationInfoimport com.intellij.openapi.ui.popup.JBPopupFactoryimport com.intellij.openapi.wm.IdeFocusManagerimport com.intellij.openapi.wm.WindowManagerimport com.intellij.psi.PsiFileimport com.intellij.ui.EditorTextFieldimport com.intellij.ui.LanguageTextFieldimport com.intellij.ui.TextFieldWithAutoCompletionimport com.intellij.ui.TextFieldWithAutoCompletionListProviderimport com.intellij.util.containers.ContainerUtilimport com.intellij.util.textCompletion.TextCompletionUtilimport org.jetbrains.annotations.Nullableimport java.awt.*import java.awt.event.*import java.beans.PropertyChangeEventimport java.beans.PropertyChangeListenerimport java.lang.Booleanimport java.nio.file.Pathimport javax.swing.*open class PijulExpertRecordDialog(val project: Project,val vcsRoot: Path,val text: String) : DialogWrapper(project, true) {private val EXPERT_MODE_GROUP =NotificationGroup.createIdWithTitle("Expert Mode", DraconBundle.message("expert.mode.notification.group.id"))init {init()title = DraconBundle.message("action.Pijul.ExpertRecord.text")}//private lateinit var editor: EditorTextField//private lateinit var field: TextFieldWithAutoCompletion<String>private lateinit var editor: CustomEditorFieldoverride fun createCenterPanel(): JComponent {val dialogPanel = JPanel(BorderLayout())val tomlLanguage = Language.findLanguageByID("TOML")val ext = FileTypeRegistry.getInstance().getFileTypeByExtension("toml")val doc = LanguageTextField.createDocument(this.text,tomlLanguage,this.project,RecordDocumentCreator())editor = CustomEditorField(tomlLanguage, project, this.text)/*val field = TextFieldWithAutoCompletion(this.project, Provider(), true, this.text)field.setOneLineMode(false)field.isViewer = false*///editor = EditorTextField(doc, this.project, ext, false, false)editor.preferredSize = Dimension(800, 600)editor.setOneLineMode(false)editor.isViewer = falseeditor.isVisible = trueeditor.isEnabled = true//field.preferredSize = Dimension(800, 600)dialogPanel.add(editor, BorderLayout.CENTER)return dialogPanel}override fun createActions(): Array<Action> {return arrayOf(RecordAction(), this.cancelAction)}override fun doOKAction() {val record = pijul(this.project).recordFromString(this.project, this.vcsRoot, this.editor.text)if (record.statusCode is SuccessStatusCode) {val hash = record.result!!.substring("Hash:".length).trim()Notifications.Bus.notify(Notification(EXPERT_MODE_GROUP,DraconBundle.message("expert.mode.notification.title"),DraconBundle.message("expert.mode.notification.success", hash),NotificationType.ERROR,),this.project)} else {record.statusCode as NonZeroExitStatusCodeNotifications.Bus.notify(Notification(EXPERT_MODE_GROUP,DraconBundle.message("expert.mode.notification.title"),DraconBundle.message("expert.mode.notification.failure", record.statusCode.exitCode, record.statusCode.message),NotificationType.INFORMATION,),this.project)}super.doOKAction()}protected inner class RecordAction() : DialogWrapper.DialogWrapperAction(DraconBundle.message("expert.mode.button.record")) {override fun doAction(e: ActionEvent?) {val infoList: List<ValidationInfo> = doValidateAll()if (infoList.isNotEmpty()) {val info = infoList[0]if (info.component != null && info.component!!.isVisible) {IdeFocusManager.getInstance(null).requestFocus(info.component!!, true)}updateErrorInfo(infoList)startTrackingValidation()if (ContainerUtil.exists(infoList) { info1: ValidationInfo -> !info1.okEnabled }) return}doOKAction()}init {addPropertyChangeListener { evt: PropertyChangeEvent ->if (NAME == evt.propertyName) {repaint()}}}}class Provider : TextFieldWithAutoCompletionListProvider<String>(listOf("author", "[[authors]]", "authors", "name", "full_name", "email")) {override fun getLookupString(item: String): String {return item}}class RecordDocumentCreator : TextCompletionUtil.DocumentWithCompletionCreator(TextFieldWithAutoCompletion.StringsCompletionProvider(listOf("author", "[[authors]]", "authors", "name", "full_name", "email"),null),true)}class CustomEditorField(language: Language?, project: Project, s: String) : LanguageTextField(language, project, s, PijulExpertRecordDialog.RecordDocumentCreator(), false) {override fun createEditor(): EditorEx {val editor = super.createEditor()editor.setVerticalScrollbarVisible(true)editor.setHorizontalScrollbarVisible(true)editor.setCaretEnabled(true)editor.isViewer = falseeditor.isOneLineMode = falseval settings = editor.settingssettings.isLineNumbersShown = truesettings.isAutoCodeFoldingEnabled = truesettings.isFoldingOutlineShown = truesettings.isAllowSingleLogicalLineFolding = truesettings.isRightMarginShown=truereturn editor}} - file addition: context[9.107]
- file addition: PijulVcsContext.kt[0.13018]
package com.github.jonathanxd.dracon.contextimport com.github.jonathanxd.dracon.PijulVcsimport com.github.jonathanxd.dracon.pijulVcsimport com.intellij.openapi.components.Serviceimport com.intellij.openapi.components.serviceIfCreatedimport com.intellij.openapi.project.Projectimport com.intellij.openapi.vcs.FilePathimport com.intellij.openapi.vcs.ProjectLevelVcsManagerimport com.intellij.openapi.vfs.VirtualFileimport java.nio.file.Pathimport java.nio.file.Pathsimport kotlin.io.path.ExperimentalPathApiimport kotlin.io.path.relativeTo@Serviceclass PijulVcsContext(val project: Project) {val root by lazy {// Currently only supports a single vcs root for pijul.ProjectLevelVcsManager.getInstance(this.project).getRootsUnderVcs(pijulVcs(this.project)).first().toNioPath()}@OptIn(ExperimentalPathApi::class)fun resolveUnderVcs(path: FilePath): Path =this.resolveUnderVcs(Paths.get(path.path))@OptIn(ExperimentalPathApi::class)fun resolveUnderVcs(path: VirtualFile): Path =this.resolveUnderVcs(path.toNioPath())@OptIn(ExperimentalPathApi::class)fun resolveUnderVcs(path: Path): Path =when {this.root.toAbsolutePath().toString() == path.toAbsolutePath().toString() -> this.rootpath.startsWith(this.root) -> pathelse -> this.root.relativize(path)}@OptIn(ExperimentalPathApi::class)fun resolveRelativeToRoot(path: Path): String =if (path.toAbsolutePath().equals(this.root.toAbsolutePath().toString()))""elsepath.toAbsolutePath().relativeTo(this.root).toString()fun isRootPath(path: Path) =this.root.toAbsolutePath().toString() == path.toAbsolutePath().toString()} - file addition: completion[9.107]
- file addition: PijulRecordFileTextCompletionProvider.kt[0.14863]
package com.github.jonathanxd.dracon.completionimport com.intellij.codeInsight.completion.CompletionParametersimport com.intellij.codeInsight.completion.CompletionResultSetimport com.intellij.codeInsight.lookup.CharFilterimport com.intellij.util.textCompletion.TextCompletionProviderclass PijulRecordFileTextCompletionProvider : TextCompletionProvider {override fun getAdvertisement(): String? {return null}override fun getPrefix(text: String, offset: Int): String? {return null}override fun applyPrefixMatcher(result: CompletionResultSet, prefix: String): CompletionResultSet =result.withPrefixMatcher(prefix)override fun acceptChar(c: Char): CharFilter.Result? {return null}override fun fillCompletionVariants(parameters: CompletionParameters, prefix: String, result: CompletionResultSet) {}} - file addition: PijulCompletionContributor.kt[0.14863]
package com.github.jonathanxd.dracon.completionimport com.intellij.codeInsight.completion.*import com.intellij.codeInsight.lookup.LookupElementBuilderimport com.intellij.patterns.PlatformPatternsimport com.intellij.util.ProcessingContextclass PijulCompletionContributor : CompletionContributor() {init {extend(CompletionType.BASIC, PlatformPatterns.psiElement(), object : CompletionProvider<CompletionParameters>() {override fun addCompletions(parameters: CompletionParameters,context: ProcessingContext,result: CompletionResultSet) {result.addElement(LookupElementBuilder.create("author"))result.addElement(LookupElementBuilder.create("[[authors]]"))result.addElement(LookupElementBuilder.create("authors"))result.addElement(LookupElementBuilder.create("name"))result.addElement(LookupElementBuilder.create("full_name"))result.addElement(LookupElementBuilder.create("email"))}})}} - edit in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 21
import com.github.jonathanxd.dracon.revision.PijulVcsFileRevision - edit in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 36
import com.intellij.vcs.log.impl.VcsUserImpl - edit in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 259[10.3744][9.13604]
}override fun revisions(project: Project, root: Path, file: Path): PijulOperationResult<List<PijulVcsFileRevision>> {val historyList = mutableListOf<PijulVcsFileRevision>()val channels = this.channel(this.project, root)val currentChannel = channels.result?.channels?.firstOrNull { it.current }?.nameval result = this.fileHistory(project, root, file, {it.hunks.filterIsInstance<HunkWithPath>().groupBy {it.resolvePath(root)}.forEach { (path, hunks) ->val deleted = hunks.any { it is FileDelHunk }historyList.add(PijulVcsFileRevision(this.project,root,path,PijulRevisionNumber(it.changeHash, it.date),it.authors.map { VcsUserImpl(it.name ?: "", it.email ?: "") }.filter { it.name.isNotEmpty() },it.message,currentChannel,deleted))}}, {})return PijulOperationResult(result.operation, result.statusCode, historyList) - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 341
val logHashExecution = this.createExecPijulOperation(project, rootPath, listOf("log", "--hash-only"), delay = 10L)return this.fileHistory(project, rootPath, filePath, consumer, errorConsumer)}@OptIn(ExperimentalPathApi::class)override fun fileHistory(project: Project,root: Path,file: Path,consumer: (PijulLogEntry) -> Unit,errorConsumer: (PijulOperationResult<Unit>) -> Unit): PijulOperationResult<Unit> {val ctx = project.service<PijulVcsContext>()val filePath = ctx.resolveUnderVcs(file)val isRootPath = ctx.isRootPath(filePath) - edit in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 357
val logHashExecution = this.createPainlessExecPijulOperation(project, root, listOf("log", "--hash-only")) - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 365
return hashes as PijulOperationResult<Unit>return hashes - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 374
val change = this.doExecutionWithMapper("change-$hash", this.createPainlessExecPijulOperation(project, rootPath, listOf("change", hash))) {val change = this.doExecutionWithMapper("change-$hash", this.createPainlessExecPijulOperation(project, root, listOf("change", hash))) { - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 386
val hunkPath = hunk.resolvePath(rootPath)val hunkPath = hunk.resolvePath(root) - edit in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 483
override fun allRevisions(project: Project, root: Path): PijulOperationResult<List<PijulRevisionNumber>> {val log = this.log(project, root)return PijulOperationResult(log.operation, log.statusCode,log.result?.entries?.map {PijulRevisionNumber(it.changeHash, it.date)})} - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 495
val channelOperation = this.createPainlessExecPijulOperation(project, rootPath, listOf("channel"))return this.channel(project, rootPath)}override fun channel(project: Project, root: Path): PijulOperationResult<ChannelInfo> {val channelOperation = this.createPainlessExecPijulOperation(project, root, listOf("channel")) - file addition: changes[9.107]
- file addition: PijulCommittedChangesProvider.kt[0.19780]
package com.github.jonathanxd.dracon.changesimport com.github.jonathanxd.dracon.PijulVcsimport com.github.jonathanxd.dracon.content.PijulContentRevisionimport com.github.jonathanxd.dracon.context.PijulVcsContextimport com.github.jonathanxd.dracon.log.*import com.github.jonathanxd.dracon.pijul.pijulimport com.github.jonathanxd.dracon.pijulVcsimport com.github.jonathanxd.dracon.revision.PijulRevisionNumberimport com.intellij.openapi.components.Serviceimport com.intellij.openapi.components.serviceimport com.intellij.openapi.project.Projectimport com.intellij.openapi.util.Pairimport com.intellij.openapi.util.io.FileUtilimport com.intellij.openapi.vcs.*import com.intellij.openapi.vcs.changes.Changeimport com.intellij.openapi.vcs.changes.ChangeListimport com.intellij.openapi.vcs.changes.ChangesUtilimport com.intellij.openapi.vcs.history.VcsFileRevisionimport com.intellij.openapi.vcs.history.VcsRevisionNumberimport com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettingsimport com.intellij.openapi.vcs.versionBrowser.ChangesBrowserSettingsEditorimport com.intellij.openapi.vcs.versionBrowser.CommittedChangeListimport com.intellij.openapi.vcs.versionBrowser.StandardVersionFilterComponentimport com.intellij.openapi.vfs.VirtualFileimport com.intellij.util.AsynchConsumerimport com.intellij.vcs.CommittedChangeListForRevisionimport com.intellij.vcs.log.VcsFullCommitDetailsimport com.intellij.vcs.log.util.VcsLogUtilimport com.intellij.vcsUtil.VcsUtilimport org.jetbrains.annotations.NotNullimport java.nio.file.Filesimport java.nio.file.Pathimport java.nio.file.Pathsimport java.util.*import javax.swing.JComponent@Serviceclass PijulCommittedChangesProvider(val project: Project) : CommittedChangesProvider<CommittedChangeList, ChangeBrowserSettings> {override fun createFilterUI(showDateFilter: Boolean): ChangesBrowserSettingsEditor<ChangeBrowserSettings> =PijulVersionFilterComponent(showDateFilter)override fun getLocationFor(root: FilePath): RepositoryLocation {val ctx = this.project.service<PijulVcsContext>()val channel = pijul(this.project).channel(this.project, ctx.root).result?.channels?.firstOrNull { it.current }?.name ?: "unknown"return PijulRepositoryLocation(ctx.root, channel)}override fun getCommittedChanges(settings: ChangeBrowserSettings,location: RepositoryLocation,maxCount: Int): MutableList<CommittedChangeList> {val changes = mutableListOf<CommittedChangeList>()this.getChanges(settings, location, maxCount) {changes.add(it)}return changes}override fun loadCommittedChanges(settings: ChangeBrowserSettings,location: RepositoryLocation,maxCount: Int,consumer: AsynchConsumer<in CommittedChangeList>) {try {getChanges(settings, location, maxCount) {consumer.consume(it)}} finally {consumer.finished()}}private fun getChanges(settings: ChangeBrowserSettings,location: RepositoryLocation,maxCount: Int,consumer: (PijulCommittedChangeList) -> Unit) {val ctx = this.project.service<PijulVcsContext>()val filters = mutableListOf<(PijulLogEntry) -> Boolean>()val beforeRev = settings.changeBeforeFilterval afterRev = settings.changeAfterFilterval beforeDate = settings.dateBeforeFilterval afterDate = settings.dateAfterFilterval author = settings.userFilterif (beforeRev != null) {filters += { entry ->entry.date.toEpochSecond() < beforeRev}}if (afterRev != null) {filters += { entry ->entry.date.toEpochSecond() > afterRev}}if (beforeDate != null) {filters += { entry ->entry.date.toInstant().isBefore(beforeDate.toInstant())}}if (afterDate != null) {filters += { entry ->entry.date.toInstant().isAfter(afterDate.toInstant())}}if (author != null) {filters += { entry ->entry.authors.any { it.name == author }}}val allRevisions = pijul(this.project).allRevisions(this.project, ctx.root).result!!pijul(this.project).log(this.project, ctx.root).result?.entries?.filter {filters.all { filter -> filter(it) }}?.map { entry ->PijulCommittedChangeList(entry.message,"",entry.authors.firstOrNull()?.name ?: "No author",Date.from(entry.date.toInstant()),entry.hunks.filterIsInstance<HunkWithPath>().map { hunk ->val beforeRevision =if (hunk is FileAddHunk) nullelse findARevisionBefore(entry.changeHash, allRevisions)?.let {PijulContentRevision(ctx.root,hunk.resolvePath(ctx.root),it,this.project)}val afterRevision =if (hunk is FileDelHunk) nullelse PijulContentRevision(ctx.root,hunk.resolvePath(ctx.root),entry.revision,this.project)Change(beforeRevision,afterRevision,hunk.status)}.toMutableList(),entry.revision,false,pijulVcs(this.project))}?.let { if (maxCount == -1) it else it.take(maxCount) }?.forEach {consumer(it)}}fun findARevisionBefore(current: String, allRevisions: List<PijulRevisionNumber>): PijulRevisionNumber? {for (i in allRevisions.indices) {if (current == allRevisions[i].hash) {return if (i == 0) {null} else {allRevisions[i - 1]}}}return null}override fun getColumns(): Array<ChangeListColumn<*>> {return arrayOf(ChangeListColumn.NUMBER,ChangeListColumn.DATE,ChangeListColumn.DESCRIPTION,ChangeListColumn.NAME)}override fun getUnlimitedCountValue(): Int = -1override fun getOneList(file: VirtualFile, number: VcsRevisionNumber): Pair<CommittedChangeList, FilePath>? {val ctx = this.project.service<PijulVcsContext>()val path = Paths.get(VcsUtil.getFilePath(file).path)val filePath = ctx.resolveUnderVcs(path)val allRevisions = pijul(this.project).allRevisions(this.project, ctx.root).result!!val rev = pijul(this.project).log(this.project, ctx.root).result?.entries?.filter {it.revision.hash == number.asString()}?.map { entry ->PijulCommittedChangeList(entry.message,"",entry.authors.firstOrNull()?.name ?: "No author",Date.from(entry.date.toInstant()),entry.hunks.filterIsInstance<HunkWithPath>().map { hunk ->val beforeRevision =if (hunk is FileAddHunk) nullelse findARevisionBefore(entry.changeHash, allRevisions)?.let {PijulContentRevision(ctx.root,hunk.resolvePath(ctx.root),it,this.project)}val afterRevision =if (hunk is FileDelHunk) nullelse PijulContentRevision(ctx.root,hunk.resolvePath(ctx.root),entry.revision,this.project)Change(beforeRevision,afterRevision,hunk.status)}.toMutableList(),entry.revision,false,pijulVcs(this.project))}?.firstOrNull() ?: return nullreturn Pair.create(rev, LocalFilePath(filePath, Files.isDirectory(filePath)))}}class PijulRepositoryLocation(val path: Path, val channel: String) : RepositoryLocation {override fun toPresentableString(): String ="${this.path}@${this.channel}"override fun getKey(): String =this.path.toString()override fun toString(): String = this.toPresentableString()}class PijulVersionFilterComponent(showDateFilter: Boolean) :StandardVersionFilterComponent<ChangeBrowserSettings>(showDateFilter) {override fun getComponent(): JComponent {return standardPanel as JComponent}init {init(ChangeBrowserSettings())}}class PijulCommittedChangeList(subject: String,comment: String,committerName: String,commitDate: Date,changes: MutableCollection<Change>,revisionNumber: VcsRevisionNumber,val modifiable: Boolean,val vcs: PijulVcs) : CommittedChangeListForRevision(subject, comment, committerName, commitDate, changes, revisionNumber) {override fun isModifiable(): Boolean = this.modifiableoverride fun getNumber(): Long =this.revisionNumber.timestamp.toInstant().epochSecondoverride fun getRevisionNumber(): PijulRevisionNumber {return super.getRevisionNumber() as PijulRevisionNumber}override fun getVcs(): AbstractVcs = this.vcs} - file addition: PijulExpertRecord.kt[9.18106]
package com.github.jonathanxd.dracon.actionsimport com.github.jonathanxd.dracon.dialog.PijulExpertRecordDialogimport com.github.jonathanxd.dracon.dialog.createPijulRecordDialogimport com.github.jonathanxd.dracon.pijul.pijulimport com.intellij.openapi.actionSystem.AnActionEventimport com.intellij.openapi.fileEditor.FileEditorManagerimport com.intellij.openapi.fileEditor.OpenFileDescriptorimport com.intellij.openapi.fileTypes.FileTypeRegistryimport com.intellij.openapi.project.DumbAwareActionimport com.intellij.openapi.vcs.ProjectLevelVcsManagerimport com.intellij.testFramework.LightVirtualFileimport com.intellij.ui.layout.panelimport kotlin.io.path.relativeToclass PijulExpertRecord : DumbAwareAction() {override fun actionPerformed(e: AnActionEvent) {val project = e.project!!val vcsManager = ProjectLevelVcsManager.getInstance(project)val root = vcsManager.allVcsRoots.first().path.toNioPath()val recordString = pijul(project).recordToString(project, root)if (recordString.result != null) {val toml = FileTypeRegistry.getInstance().getFileTypeByExtension("toml")//val editor = EditorTextField(recordString.result, this.project, )/*val psiFile = PsiDocumentManager.getInstance(editor.getProject()).getPsiFile(editor.getDocument())val element = psiFile!!.findElementAt(editor.getCaretModel().getOffset())val code: PsiExpressionCodeFragment = JavaCodeFragmentFactory.getInstance(editor.getProject()).createExpressionCodeFragment("", element, null, true)val document: Document? = PsiDocumentManager.getInstance(editor.getProject()).getDocument(code)val myInput = EditorTextField(document, editor.getProject(), JavaFileType.INSTANCE)*/PijulExpertRecordDialog(project, root, recordString.result).showAndGet()/*FileEditorManager.getInstance(project).openTextEditor(OpenFileDescriptor(project, LightVirtualFile("record", toml, recordString.result)),true)*/}}} - edit in src/main/kotlin/com/github/jonathanxd/dracon/PijulVcs.kt at line 13
import com.github.jonathanxd.dracon.changes.PijulCommittedChangesProvider - edit in src/main/kotlin/com/github/jonathanxd/dracon/PijulVcs.kt at line 23
import com.intellij.openapi.vcs.CommittedChangesProvider - edit in src/main/kotlin/com/github/jonathanxd/dracon/PijulVcs.kt at line 31
import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList - edit in src/main/kotlin/com/github/jonathanxd/dracon/PijulVcs.kt at line 75
override fun getCommittedChangesProvider(): CommittedChangesProvider<out CommittedChangeList, *>? =project.service<PijulCommittedChangesProvider>()