Improved caching code a lot
[?]
Apr 4, 2021, 12:07 PM
37OJKSWJFDRHNWQW6P7HSZX6OWZWVNCJ2IFT42O5TANQF7VOVX6ACDependencies
- [2]
A7JOR7M3Fixed the link and added a better description for download the .zip - [3]
G54TB4QZtypo fix - [4]
2N67RQZCAdd auto installation support and cache content of ContentRevision - [5]
B43WNBLF- Add Show History to Pijul menu - Always ignore .idea and .pijul in tracking. - Make findPijul a generic function to allow to find editor-server. - Only show one revision for directories. - Add `Hunk::resolvePath(Path)` to resolve the affected file to a Java NIO Path. - Fix StringOutOfBounds in Change Parsering Algorithm - Use editor-server instead of copie for interfacing with `pijul record` file. - Fix FileStatus provider not returning correctly for untracked files. - Add CommittedChangesProvider for Pijul. - [6]
Q35OTML2Remove use of coroutines, which was blocking IntelliJ UI in larger repositories Improvements for bigger repositories, now Dracon caches the changes that happened in a revision in a file, so everytime Dracon needs to query the changes of a revision, it loads directly from memory instead of doing a full-scan in Pijul repository. For tiny projects it is not a problem, but for medium ones it takes more than five minutes to scan the entire repository (and it was tested with a repo of only 700 records, however there was changes that had more than 60.000 lines). The cache file is saved in IntelliJ Data Path (project specific) and is compressed with gzip, so it will not use so much disk space (the cost worths the gains). - [7]
GGYFPXNDInitial plugin - [8]
MTPTFTHGInitial plugin 2 - [9]
PGNTR2EPImproved README and ider roadmap - [10]
FNNW5IEAAdded more plugin files to Pijul - [11]
Q7FXTHVUFirst record support, YEAAAH, RECOOORD - [12]
ZCRW57C5Improved support for revisions - [13]
OPFG6CZ2File status tracking supported. - [14]
7L5LODGZParse changes from `pijul change` - [15]
6CR2EFUNFirst ChangeProvider implementation!!! Wheehooo - [16]
MZYZIVHYFirst experimental build, it seems like it is breaking Git plugin, however, it still something =D - [17]
EAGIDXOLBuild 2 to only listen to changes in project under pijul - [18]
5AUENX2YAdd support to view files affected by a revision - [19]
QXUEMZ3BInitial CahngeProvider - [20]
ISO7J5ZHMore caches, better and generic cache code. Now Dracon listen to file changes to drop cached data. Implemented caches: - File contents in specific revision (never dropped) - Pijul ls and Pijul diff results - File Revision and File changes by patch - some others.. Dracon is incredible fast now, but still will take some time for bigger repos. - [21]
NTRPUMVQImproved README and added roadmap. - [22]
MJDBCNFHMoved builds to builds dir - [23]
FRFFQV7VBasic show history support.
Change contents
- replacement in src/test/kotlin/com/github/jonathanxd/dracon/test/DraconTest.kt at line 434
println(sources) - file addition: DraconCreditTest.kt[5.11189]
package com.github.jonathanxd.dracon.testimport com.github.jonathanxd.dracon.log.*import com.github.jonathanxd.dracon.pijul.credit.parseCreditimport io.kotest.core.spec.style.ShouldSpecimport io.kotest.matchers.shouldBeimport java.time.ZoneOffsetimport java.time.ZonedDateTimeclass DraconCreditTest : ShouldSpec({should("correctly parse a 'pijul credit' text with example credit") {val text = """GGYFPXND4VBCQNTRPUMVQHUIQY> #> # 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.> #>GGYFPXND4VBCQ, NTRPUMVQHUIQY> dracon.vcs.name=Pijul> dracon.vcs.name.with.mnemonic=_PijulQ7FXTHVUPVAFM>GGYFPXND4VBCQ, Q7FXTHVUPVAFM>MTPTFTHGAOKQG> action.Pijul.Init.text=Create Pijul Repository> action.Pijul.Add.text=Add Files...ZCRW57C5MSBXY> action.Pijul.ExpertRecord.text=Record (Expert Mode)...2N67RQZCVGL6G> action.Pijul.InvalidateCaches.text=Invalidate CachesZCRW57C5MSBXY, 2N67RQZCVGL6G, MTPTFTHGAOKQG> action.Pijul.Commit.And.Push.text=Commit And Push...GGYFPXND4VBCQ, MTPTFTHGAOKQG> init.title=Create Pijul Repository> init.description=Select the target directory to init Pijul repository.> init.warning.title=Pijul Init> init.warning.already.under.pijul=The directory <tt>{0}</tt> is already under Pijul.\n\Q7FXTHVUPVAFM, MTPTFTHGAOKQG> Are you sure that you want to create a new VCS root?> init.error=Failed to initialize Pijul repository.>> dracon.refresh=Refreshing Pijul Repository>ZCRW57C5MSBXY, Q7FXTHVUPVAFM> group.Pijul.Menu.text=_Pijul>> record.action.name=RecordZCRW57C5MSBXY, 2N67RQZCVGL6G> record.author=&Author:> record.expert.mode.title=Record (Expert Mode)>> expert.mode.button.record=Record> expert.mode.button.cancel=Cancel>> expert.mode.notification.group.id=Expert mode> expert.mode.notification.title=Record (expert mode)> expert.mode.notification.success=Successfully recorded changes. New revision: <tt>{0}</tt>.2N67RQZCVGL6G> expert.mode.notification.failure=Failed to record changes with exit code <bold>{0}</bold> and message: <tt>{1}</tt>.>> cache.invalidate.text=Invalidating caches...> cache.invalidate.current.text=Invalidating <em>{0}</em>...> cache.invalidate.finish.text=Invalidated caches>> install.pijul.title=Install pijul> install.pijul.title2=Install Pijul> install.pijul.text=Cannot find pijul binaries.\n\> Do you want to install pijul using rust cargo?>> install.editor.server.title=Install editor-server> install.editor.server.title2=Install Editor Server> install.editor.server.text=Cannot find editor-server binaries.\n\> Dracon depends on editor-server for interfacing with Pijul.\n\> Do you want to install editor-server using rust cargo?>> install.cargo.title=Install Rustup and Cargo> install.cargo.text=In order to install <tt>{0}</tt> you need to have cargo installed.\n\> However we cannot find cargo installed in this machine.\n\> Do you want to install rustup with cargo?\n\> If you agree, we will download rustup and launch the installer, you take from there.>> install.pijul.warning.text=You won't be able to use Dracon plugin since some dependencies could not be installed.>> install.cargo.running.text=Running cargo install...""".trimIndent()val credit = text.parseCredit()credit.toString() shouldBe "PijulCredit(header=[GGYFPXND4VBCQ], entries=[PijulCreditEntry(shortHash=[NTRPUMVQHUIQY], data=[#, # 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., #, ]), PijulCreditEntry(shortHash=[GGYFPXND4VBCQ, NTRPUMVQHUIQY], data=[dracon.vcs.name=Pijul, dracon.vcs.name.with.mnemonic=_Pijul]), PijulCreditEntry(shortHash=[Q7FXTHVUPVAFM], data=[]), PijulCreditEntry(shortHash=[GGYFPXND4VBCQ, Q7FXTHVUPVAFM], data=[]), PijulCreditEntry(shortHash=[MTPTFTHGAOKQG], data=[action.Pijul.Init.text=Create Pijul Repository, action.Pijul.Add.text=Add Files...]), PijulCreditEntry(shortHash=[ZCRW57C5MSBXY], data=[action.Pijul.ExpertRecord.text=Record (Expert Mode)...]), PijulCreditEntry(shortHash=[2N67RQZCVGL6G], data=[action.Pijul.InvalidateCaches.text=Invalidate Caches]), PijulCreditEntry(shortHash=[ZCRW57C5MSBXY, 2N67RQZCVGL6G, MTPTFTHGAOKQG], data=[action.Pijul.Commit.And.Push.text=Commit And Push...]), PijulCreditEntry(shortHash=[GGYFPXND4VBCQ, MTPTFTHGAOKQG], data=[init.title=Create Pijul Repository, init.description=Select the target directory to init Pijul repository., init.warning.title=Pijul Init, init.warning.already.under.pijul=The directory <tt>{0}</tt> is already under Pijul.\\n\\]), PijulCreditEntry(shortHash=[Q7FXTHVUPVAFM, MTPTFTHGAOKQG], data=[ Are you sure that you want to create a new VCS root?, init.error=Failed to initialize Pijul repository., , dracon.refresh=Refreshing Pijul Repository, ]), PijulCreditEntry(shortHash=[ZCRW57C5MSBXY, Q7FXTHVUPVAFM], data=[group.Pijul.Menu.text=_Pijul, , record.action.name=Record]), PijulCreditEntry(shortHash=[ZCRW57C5MSBXY, 2N67RQZCVGL6G], data=[record.author=&Author:, record.expert.mode.title=Record (Expert Mode), , expert.mode.button.record=Record, expert.mode.button.cancel=Cancel, , expert.mode.notification.group.id=Expert mode, expert.mode.notification.title=Record (expert mode), expert.mode.notification.success=Successfully recorded changes. New revision: <tt>{0}</tt>.]), PijulCreditEntry(shortHash=[2N67RQZCVGL6G], data=[expert.mode.notification.failure=Failed to record changes with exit code <bold>{0}</bold> and message: <tt>{1}</tt>., , cache.invalidate.text=Invalidating caches..., cache.invalidate.current.text=Invalidating <em>{0}</em>..., cache.invalidate.finish.text=Invalidated caches, , install.pijul.title=Install pijul, install.pijul.title2=Install Pijul, install.pijul.text=Cannot find pijul binaries.\\n\\, Do you want to install pijul using rust cargo?, , install.editor.server.title=Install editor-server, install.editor.server.title2=Install Editor Server, install.editor.server.text=Cannot find editor-server binaries.\\n\\, Dracon depends on editor-server for interfacing with Pijul.\\n\\, Do you want to install editor-server using rust cargo?, , install.cargo.title=Install Rustup and Cargo, install.cargo.text=In order to install <tt>{0}</tt> you need to have cargo installed.\\n\\, However we cannot find cargo installed in this machine.\\n\\, Do you want to install rustup with cargo?\\n\\, If you agree, we will download rustup and launch the installer, you take from there., , install.pijul.warning.text=You won't be able to use Dracon plugin since some dependencies could not be installed., , install.cargo.running.text=Running cargo install...])])"}}) - edit in src/main/resources/messages/DraconBundle.properties at line 20
action.Pijul.AddToIgnore.text=Add To .ignore - edit in src/main/resources/messages/DraconBundle.properties at line 67
install.cargo.running.text=Running cargo install... - replacement in src/main/resources/messages/DraconBundle.properties at line 70
install.cargo.running.text=Running cargo install...[4.1229]index.revision.text=Indexing files revisions.index.reset.text=Resetting working directory...index.item.description.text=Indexing <tt>{0}</tt>...index.item.description.finish.text=Finished!index.unrecord.description.text=Un-recording changes...index.ls.text=Listing tracked files...index.revision.loading.text=Loading revisions...index.revision.files.text=Working on files...index.revision.description.text=Working on revision {0}...index.revision.file.description.text=Loading file {0} of revision {1}... - edit in src/main/resources/META-INF/plugin.xml at line 30
<vcsIgnoreChecker implementation="com.github.jonathanxd.dracon.ignore.PijulIgnoreChecker"/> - edit in src/main/resources/META-INF/plugin.xml at line 34
<backgroundPostStartupActivity implementation="com.github.jonathanxd.dracon.activity.PijulIndexActivity"/> - edit in src/main/resources/META-INF/plugin.xml at line 36
<!-- Pijul ignore lang --><fileType language="PijulIgnore" extensions="ignore" fieldName="INSTANCE" name="PijulIgnore file"implementationClass="com.github.jonathanxd.dracon.lang.ignore.PijulIgnoreFileType"/><lang.parserDefinition language="PijulIgnore"implementationClass="com.intellij.openapi.vcs.changes.ignore.lang.IgnoreParserDefinition"/><codeInsight.lineMarkerProvider language="PijulIgnore"implementationClass="com.intellij.openapi.vcs.changes.ignore.codeInsight.IgnoreDirectoryMarkerProvider"/><lang.braceMatcher language="PijulIgnore" implementationClass="com.intellij.openapi.vcs.changes.ignore.lang.IgnoreBraceMatcher"/><lang.commenter language="PijulIgnore" implementationClass="com.intellij.openapi.vcs.changes.ignore.lang.IgnoreCommenter"/><!--END Pijul ignore lang--> - replacement in src/main/resources/META-INF/plugin.xml at line 59
<action id="Pijul.InvalidateCaches" class="com.github.jonathanxd.dracon.actions.PijulInvalidateCaches"></action><action id="Pijul.InvalidateCaches" class="com.github.jonathanxd.dracon.actions.PijulInvalidateCaches"/><action id="Pijul.AddToIgnore" class="com.github.jonathanxd.dracon.actions.PijulAddToIgnore"/> - edit in src/main/resources/META-INF/plugin.xml at line 90
</group><group id="Pijul.Ignore.File" class="com.github.jonathanxd.dracon.actions.PijulIgnoreActionGroup"><add-to-group group-id="ChangesViewPopupMenu" anchor="after" relative-to-action="ChangesView.AddUnversioned"/><add-to-group group-id="Pijul.Menu" anchor="after" relative-to-action="Pijul.Add"/><add-to-group group-id="Unversioned.Files.Dialog.Popup" anchor="after" relative-to-action="$Delete"/> - edit in src/main/kotlin/com/github/jonathanxd/dracon/revision/RevisionContentResolver.kt at line 3
import com.github.jonathanxd.dracon.i18n.DraconBundle - edit in src/main/kotlin/com/github/jonathanxd/dracon/revision/RevisionContentResolver.kt at line 6
import com.intellij.openapi.progress.ProgressIndicatorimport com.intellij.openapi.progress.forEachWithProgress - replacement in src/main/kotlin/com/github/jonathanxd/dracon/revision/RevisionContentResolver.kt at line 15
import java.util.Comparatorimport java.util.* - replacement in src/main/kotlin/com/github/jonathanxd/dracon/revision/RevisionContentResolver.kt at line 54
val tempDir = FileUtilRt.createTempDirectory("dracon_diffs-", revisionHash)if (Files.isDirectory(filePath)) {// Will always fail for directories.return ""}val tempDir = FileUtilRt.createTempDirectory("dracon_diffs-", revisionHash + UUID.randomUUID().toString()) - edit in src/main/kotlin/com/github/jonathanxd/dracon/revision/RevisionContentResolver.kt at line 85
} finally {FileUtilRt.delete(tempDir)}}@OptIn(ExperimentalPathApi::class)fun loadStateInRevisionForAllFiles(revisionHash: String,project: Project,root: Path,i: ProgressIndicator): Map<Path, ByteArray> {val tempDir = FileUtilRt.createTempDirectory("dracon_diffs-all-", revisionHash + UUID.randomUUID().toString())val tmpTarget = tempDir.toPath()val pathToRevisionState = mutableMapOf<Path, ByteArray>()copyFolder(root, tmpTarget, StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING)val revisions = pijul(project).latestRevisionNumber(project, tmpTarget).resulti.text2 = DraconBundle.message("index.reset.text")val reset = pijul(project).reset(project, tmpTarget)if (reset.statusCode !is SuccessStatusCode) {throw IllegalStateException("Failed to load state of all files in revision $revisionHash during reset. $revisions")}i.fraction += 0.0001if (revisions == null || revisions.hash != revisionHash) {i.text2 = DraconBundle.message("index.unrecord.description.text")val rollbackOp = pijul(project).rollbackTo(revisionHash, project, tmpTarget)if (rollbackOp.statusCode !is SuccessStatusCode) {throw IllegalStateException("Failed to load state of all files in revision $revisionHash during unrecord. $rollbackOp")}i.fraction += 0.0001}i.text2 = DraconBundle.message("index.ls.text")val ls = pijul(project).trackedFiles(project, tmpTarget)if (ls.statusCode !is SuccessStatusCode) {throw IllegalStateException("Failed to load state of all files in revision $revisionHash during reset. $revisions")}i.fraction += 0.0001val trackedFiles = ls.result!!trackedFiles.forEachWithProgress(i) { it, indic ->indic.text2 = DraconBundle.message("index.item.description.text", it.toString())if (Files.isRegularFile(it)) {pathToRevisionState[it] = Files.readAllBytes(it)}}i.text2 = DraconBundle.message("index.item.description.finish.text")try {return pathToRevisionState} finally {FileUtilRt.delete(tempDir)}}@OptIn(ExperimentalPathApi::class)fun loadStateInEveryRevisionForAllFiles(allRevisions: List<String>,project: Project,root: Path,i: ProgressIndicator): Map<String, Map<Path, ByteArray>> {if (allRevisions.isEmpty()) {throw IllegalArgumentException("Provided 'allRevisions' argument must not be empty.")}val tempDir = FileUtilRt.createTempDirectory("dracon_diffs-all-","${allRevisions.size}-" + UUID.randomUUID().toString())val tmpTarget = tempDir.toPath()val revisionToPathToState = mutableMapOf<String, MutableMap<Path, ByteArray>>()copyFolder(root, tmpTarget, StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING)val revisions = pijul(project).allRevisions(project, tmpTarget)if (revisions.statusCode !is SuccessStatusCode) {throw IllegalStateException("Failed to load state of all files in revisions '$allRevisions' during all revisions hash retrieval. $revisions")}val pijulRevisions = revisions.result!!.map { it.hash }val indexOfFirstRevision = pijulRevisions.indexOf(allRevisions[0])if (indexOfFirstRevision == -1) {throw IllegalArgumentException("Could not find revision ${allRevisions[0]} in Pijul repository!")} else {if (indexOfFirstRevision + allRevisions.size >= pijulRevisions.size) {throw IllegalArgumentException("There are more revisions to unrecord than the amount of recorded changes in Pijul Repository.")} else {val revisionSubList = pijulRevisions.subList(indexOfFirstRevision, indexOfFirstRevision + allRevisions.size)if (allRevisions != revisionSubList) {throw IllegalArgumentException("Revisions to load must sequentially match a sub sequence of revisions in Pijul repository. " +"Changes found in pijul: $revisionSubList. Changes to unrecord: $allRevisions")}}}i.text2 = DraconBundle.message("index.reset.text")val reset = pijul(project).reset(project, tmpTarget)if (reset.statusCode !is SuccessStatusCode) {throw IllegalStateException("Failed to load state of all files in revisions '$allRevisions' during reset. $reset")}i.fraction += 0.0001allRevisions.withIndex().toList().forEachWithProgress(i) { (index, rev), indicator ->val pathToRevisionState = revisionToPathToState.computeIfAbsent(rev) { mutableMapOf() }indicator.text2 = DraconBundle.message("index.revision.description.text", rev)if (index == 0) {val rollback = pijul(project).rollbackTo(rev, project, tmpTarget)if (rollback.statusCode !is SuccessStatusCode) {throw IllegalStateException("Failed to load state of all files in revision '$rev' during rollback. $rollback")}} else {val unrecord = pijul(project).unrecord(project, tmpTarget, rev)if (unrecord.statusCode !is SuccessStatusCode) {throw IllegalStateException("Failed to load state of all files in revision '$rev' during unrecord. $unrecord")}}indicator.text2 = DraconBundle.message("index.ls.text")val ls = pijul(project).trackedFiles(project, tmpTarget)if (ls.statusCode !is SuccessStatusCode) {throw IllegalStateException("Failed to load state of all files in revision $rev during tracked file listing. $ls")}indicator.fraction += 0.0001val trackedFiles = ls.result!!trackedFiles.forEachWithProgress(indicator) { it, indic ->indic.text2 = DraconBundle.message("index.item.description.text", it.toString())if (Files.isRegularFile(it)) {val relativeToRoot = root.resolve(it.relativeTo(tmpTarget))pathToRevisionState[relativeToRoot] = Files.readAllBytes(it)}}}i.text2 = DraconBundle.message("index.item.description.finish.text")try {return revisionToPathToState - edit in src/main/kotlin/com/github/jonathanxd/dracon/revision/RevisionContentResolver.kt at line 247
- edit in src/main/kotlin/com/github/jonathanxd/dracon/provider/PijulHistoryProvider.kt at line 26
import java.nio.file.Files - edit in src/main/kotlin/com/github/jonathanxd/dracon/provider/PijulHistoryProvider.kt at line 29
import kotlin.io.path.ExperimentalPathApiimport kotlin.io.path.nameimport kotlin.io.path.relativeTo - edit in src/main/kotlin/com/github/jonathanxd/dracon/provider/PijulHistoryProvider.kt at line 103
@OptIn(ExperimentalPathApi::class) - replacement in src/main/kotlin/com/github/jonathanxd/dracon/provider/PijulHistoryProvider.kt at line 121
val deleted = it.hunks.filterIsInstance<HunkWithPath>().filter {/*val deleted = it.hunks.filterIsInstance<HunkWithPath>().filter { - replacement in src/main/kotlin/com/github/jonathanxd/dracon/provider/PijulHistoryProvider.kt at line 136
)/*// TODO: Should we limit to show only one revision when introspecting directories instead of all revisions?)*/// 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/provider/PijulHistoryProvider.kt at line 142
if (!Files.isDirectory(path)) {val msg = if (Files.isDirectory(pathToView)) {"File ${path.name}"} else {it.message.replace("\n", " ").trim()} - replacement in src/main/kotlin/com/github/jonathanxd/dracon/provider/PijulHistoryProvider.kt at line 149
partner.acceptRevision(PijulVcsFileRevision(this.project,root.toNioPath(),path,PijulRevisionNumber(it.changeHash, it.date),it.authors.map { VcsUserImpl(it.name ?: "", it.email ?: "") }.filter { it.name.isNotEmpty() },it.message,currentChannel,deletedpartner.acceptRevision(PijulVcsFileRevision(this.project,root.toNioPath(),path,PijulRevisionNumber(it.changeHash, it.date),it.authors.map { VcsUserImpl(it.name ?: "", it.email ?: "") }.filter { it.name.isNotEmpty() },msg,currentChannel,deleted) - replacement in src/main/kotlin/com/github/jonathanxd/dracon/provider/PijulHistoryProvider.kt at line 161
)}*/}} - edit in src/main/kotlin/com/github/jonathanxd/dracon/provider/PijulChangeProvider.kt at line 4
import com.github.jonathanxd.dracon.cache.PijulLogRevisionCache - edit in src/main/kotlin/com/github/jonathanxd/dracon/provider/PijulChangeProvider.kt at line 24
private val logRevisionCache = project.service<PijulLogRevisionCache>() - replacement in src/main/kotlin/com/github/jonathanxd/dracon/provider/PijulChangeProvider.kt at line 56
val head = this.logEntryChangeCache.loadRevision(rootAbsolute) {val head = this.logRevisionCache.loadRevision(rootAbsolute) { - file addition: credit[5.3420]
- file addition: PijulCredit.kt[0.19694]
package com.github.jonathanxd.dracon.pijul.creditimport com.github.jonathanxd.dracon.log.substringUntilimport java.io.Serializabledata class PijulCredit(val header: List<String>,val entries: List<PijulCreditEntry>): Serializable {companion object {const val serialVersionUID = 1L}}data class PijulCreditEntry(val shortHash: List<String>, val data: List<String>): Serializable {companion object {const val serialVersionUID = 1L}}fun String.parseCredit(): PijulCredit {val header = mutableListOf<String>()val lines = mutableListOf<PijulCreditEntry>()var shortHashes: List<String>? = nullvar pointer = 0while (pointer > -1) {if (pointer < this.length && this[pointer] == '\n') {pointer += 1continue}if (pointer == this.length) {break}val line = this.substringUntil(pointer, '\n', includeChar = false)if (line.isNotEmpty() && line.isNotBlank()) {if (!line.startsWith(">")) {if (shortHashes != null) {header.addAll(shortHashes)}shortHashes = line.split(",").map { it.trim() }} else {val hashes = shortHashes?: throw IllegalStateException("Something wrong happened during credit parsing")val data = mutableListOf<String>()var dataLine = linewhile (dataLine.startsWith("> ") && pointer > -1) {data.add(dataLine.substring("> ".length))if (pointer + 1 >= this.length) {break;}pointer = this.indexOf("\n", pointer + 1)if (pointer == -1) {break}while (pointer < this.length && this[pointer] == '\n') {pointer += 1if (pointer == this.length) {break}}dataLine = this.substringUntil(pointer, '\n', includeChar = false)}shortHashes = nulllines += PijulCreditEntry(hashes, data)if (!dataLine.startsWith("> ") && line.isNotEmpty() && line.isNotBlank()) {shortHashes = dataLine.split(",").map { it.trim() }}}}if (pointer == -1) {break}if (pointer + 1 >= this.length) {break;}pointer = this.indexOf("\n", pointer + 1)}if (shortHashes != null) {header.addAll(shortHashes)}return PijulCredit(header, lines)} - edit in src/main/kotlin/com/github/jonathanxd/dracon/pijul/Pijul.kt at line 17
import com.github.jonathanxd.dracon.pijul.credit.PijulCredit - edit in src/main/kotlin/com/github/jonathanxd/dracon/pijul/Pijul.kt at line 90
fun trackedFiles(project: Project, root: Path): PijulOperationResult<List<Path>> - edit in src/main/kotlin/com/github/jonathanxd/dracon/pijul/Pijul.kt at line 106
fun unrecord(project: Project, root: Path, hash: String): PijulOperationResult<Boolean>@RequiresBackgroundThread - edit in src/main/kotlin/com/github/jonathanxd/dracon/pijul/Pijul.kt at line 176
/*** Retrieves change history*/@RequiresBackgroundThreadfun credit(project: Project, root: Path, file: Path): PijulOperationResult<PijulCredit> - edit in src/main/kotlin/com/github/jonathanxd/dracon/listeners/PijulAsyncFileListener.kt at line 5
import com.github.jonathanxd.dracon.cache.PijulLogRevisionCache - edit in src/main/kotlin/com/github/jonathanxd/dracon/listeners/PijulAsyncFileListener.kt at line 21
private val pijulLogRevisionCache by lazy { this.project.service<PijulLogRevisionCache>() } - edit in src/main/kotlin/com/github/jonathanxd/dracon/listeners/PijulAsyncFileListener.kt at line 38
this.pijulLogRevisionCache.unload(Paths.get(VcsUtil.getFilePath(file).path)) - file addition: lang[5.107]
- file addition: ignore[0.23277]
- file addition: PijulIgnoreLanguage.kt[0.23287]
package com.github.jonathanxd.dracon.lang.ignoreimport com.intellij.openapi.vcs.changes.ignore.lang.IgnoreFileTypeimport com.intellij.openapi.vcs.changes.ignore.lang.IgnoreLanguageimport com.intellij.openapi.vcs.changes.ignore.lang.Syntaxobject PijulIgnoreLanguage : IgnoreLanguage("PijulIgnore", "ignore") {override fun getFileType(): IgnoreFileType = PijulIgnoreFileTypeoverride fun isSyntaxSupported(): Boolean = trueoverride fun getDefaultSyntax(): Syntax = Syntax.REGEXP} - file addition: PijulIgnoreFileType.kt[0.23287]
package com.github.jonathanxd.dracon.lang.ignoreimport com.intellij.openapi.vcs.changes.ignore.lang.IgnoreFileTypeobject PijulIgnoreFileType : IgnoreFileType(PijulIgnoreLanguage) - file addition: ignore[5.107]
- file addition: PijulIgnoreChecker.kt[0.24032]
package com.github.jonathanxd.dracon.ignoreimport com.github.jonathanxd.dracon.PijulVcsimport com.intellij.openapi.vcs.IgnoredCheckResultimport com.intellij.openapi.vcs.VcsIgnoreCheckerimport com.intellij.openapi.vcs.VcsKeyimport com.intellij.openapi.vfs.VirtualFileimport java.nio.file.Pathclass PijulIgnoreChecker : VcsIgnoreChecker {override fun getSupportedVcs(): VcsKey = PijulVcs.KEYoverride fun isIgnored(vcsRoot: VirtualFile, file: Path): IgnoredCheckResult {TODO("Not yet implemented")}override fun isFilePatternIgnored(vcsRoot: VirtualFile, filePattern: String): IgnoredCheckResult {TODO("Not yet implemented")}} - edit in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 24
import com.github.jonathanxd.dracon.pijul.credit.PijulCreditimport com.github.jonathanxd.dracon.pijul.credit.parseCredit - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 88
val execution = this.createExecPijulOperation(project, path, listOf("add", "-r") + pathList)val execution = if (pathList.all { Files.isRegularFile(path.resolve(it)) }) {this.createExecPijulOperation(project, path, listOf("add") + pathList)} else {this.createExecPijulOperation(project, path, listOf("add", "-r") + pathList)} - edit in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 198
@OptIn(ExperimentalPathApi::class)override fun credit(project: Project, root: Path, file: Path): PijulOperationResult<PijulCredit> {val filePath = file.relativeTo(root).toString()val credit = this.doExecutionWithMapper("credit",this.createExecPijulOperation(project, root, listOf("credit", filePath))) {if (it.isEmpty() || it.trim().isEmpty() || it.trim().isBlank()) nullelse it.parseCredit()}return credit} - edit in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 250
override fun trackedFiles(project: Project, root: Path): PijulOperationResult<List<Path>> {return this.doExecutionWithMapper("tracked_files_from_ls", this.createExecPijulOperation(project, root, listOf("ls"), log = false)) {it.split("\n").map {root.resolve(it)}}} - edit in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 296
}}override fun unrecord(project: Project, root: Path, hash: String): PijulOperationResult<Boolean> {val unrecord = this.doExecution("unrecord_$hash",this.createPainlessExecPijulOperation(project, root, listOf("unrecord", "--reset", hash)))if (unrecord.statusCode !is SuccessStatusCode) {return unrecord as PijulOperationResult<Boolean> - edit in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 308
val reset = this.reset(project, root)if (reset.statusCode !is SuccessStatusCode) {return reset}return PijulOperationResult("unrecord_${hash}", SuccessStatusCode, true) - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cmd/PijulCmd.kt at line 698
PijulOperationResult(name, NonZeroExitStatusCode(status, error), Unit) as PijulOperationResult<T>PijulOperationResult(name, NonZeroExitStatusCode(status, error), null) as PijulOperationResult<T> - file addition: PijulLogRevisionCache.kt[5.8571]
package com.github.jonathanxd.dracon.cacheimport com.github.jonathanxd.dracon.context.PijulVcsContextimport com.github.jonathanxd.dracon.log.PijulLogEntryimport com.github.jonathanxd.dracon.pijul.PijulOperationResultimport com.github.jonathanxd.dracon.pijul.SuccessStatusCodeimport com.github.jonathanxd.dracon.revision.PijulRevisionNumberimport com.intellij.openapi.components.Serviceimport com.intellij.openapi.components.serviceimport com.intellij.openapi.project.Projectimport java.nio.file.Pathimport kotlin.io.path.ExperimentalPathApiimport kotlin.io.path.relativeTo@Suppress("UnstableApiUsage")@OptIn(ExperimentalPathApi::class)@Serviceclass PijulLogRevisionCache(val project: Project): CacheService<String, PijulRevisionNumber> {override val cache = DataCache<String, PijulRevisionNumber>(project, "revision")fun loadRevision(path: Path, compute: () -> PijulOperationResult<PijulRevisionNumber>): PijulOperationResult<PijulRevisionNumber> {val ctx = this.project.service<PijulVcsContext>()val relativePath = path.relativeTo(ctx.root).toString()return this.cache.queryOrLoad(relativePath,{ compute() },{ it.statusCode is SuccessStatusCode },{it.result!!},{ PijulOperationResult("revision", SuccessStatusCode, it) })}fun unload(path: Path) {val ctx = this.project.service<PijulVcsContext>()val relativePath = path.relativeTo(ctx.root).toString()this.invalidate(relativePath)}override fun invalidate(key: String) {super.invalidate(key)this.cache.unload("")}} - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/PijulLogEntryChangeCache.kt at line 18
class PijulLogEntryChangeCache(val project: Project) {private val dataCache = DataCache<String, PijulLogEntry>(project, "path_change")private val revisionDataCache = DataCache<String, PijulRevisionNumber>(project, "revision")class PijulLogEntryChangeCache(val project: Project): CacheService<String, PijulLogEntry> {override val cache = DataCache<String, PijulLogEntry>(project, "path_change") - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/PijulLogEntryChangeCache.kt at line 25
return this.dataCache.queryOrLoad(relativePath,return this.cache.queryOrLoad(relativePath, - edit in src/main/kotlin/com/github/jonathanxd/dracon/cache/PijulLogEntryChangeCache.kt at line 30
)}fun loadRevision(path: Path, compute: () -> PijulOperationResult<PijulRevisionNumber>): PijulOperationResult<PijulRevisionNumber> {val ctx = this.project.service<PijulVcsContext>()val relativePath = path.relativeTo(ctx.root).toString()return this.revisionDataCache.queryOrLoad(relativePath,{ compute() },{ it.statusCode is SuccessStatusCode },{it.result!!},{ PijulOperationResult("revision", SuccessStatusCode, it) } - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/PijulLogEntryChangeCache.kt at line 36
this.dataCache.unload(relativePath)this.dataCache.unload("")this.revisionDataCache.unload(relativePath)this.revisionDataCache.unload("")this.invalidate(relativePath) - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/PijulLogEntryChangeCache.kt at line 39
fun invalidate() {this.dataCache.invalidate()this.revisionDataCache.invalidate()override fun invalidate(key: String) {super.invalidate(key)this.cache.unload("") - edit in src/main/kotlin/com/github/jonathanxd/dracon/cache/PijulLogEntryChangeCache.kt at line 43
- replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/PijulLogEntryCache.kt at line 11
class PijulLogEntryCache(val project: Project) {private val dataCache = DataCache<String, PijulLogEntry>(project, "change")class PijulLogEntryCache(val project: Project): CacheService<String, PijulLogEntry> {override val cache = DataCache<String, PijulLogEntry>(project, "change") - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/PijulLogEntryCache.kt at line 15
return this.dataCache.queryOrLoad(hash,return this.cache.queryOrLoad(hash, - edit in src/main/kotlin/com/github/jonathanxd/dracon/cache/PijulLogEntryCache.kt at line 22[4.2665]→[4.2665:2725](∅→∅),[4.2725]→[5.13103:13109](∅→∅),[5.17147]→[5.13103:13109](∅→∅),[5.13103]→[5.13103:13109](∅→∅)
fun invalidate() {this.dataCache.invalidate()} - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/FileStatusCache.kt at line 19
class FileStatusCache(val project: Project) {private val cache = DataCache<String, CacheablePijulFileStatus>(this.project, "file_status")class FileStatusCache(val project: Project): CacheService<String, CacheablePijulFileStatus> {override val cache = DataCache<String, CacheablePijulFileStatus>(this.project, "file_status") - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/FileStatusCache.kt at line 63
this.cache.unload(relativePath)this.invalidate(relativePath) - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/FileStatusCache.kt at line 66
fun invalidate() {this.cache.invalidate()fun updateCache(path: Path, newValueCompute: () -> CacheablePijulFileStatus) {val ctx = this.project.service<PijulVcsContext>()val relativePath = path.relativeTo(ctx.root).toString()super.updateCache(relativePath, newValueCompute)}fun updateCacheForPaths(paths: List<Path>, newValueCompute: (Path) -> CacheablePijulFileStatus) {val ctx = this.project.service<PijulVcsContext>()val relativePathMap = paths.associateBy { it.relativeTo(ctx.root).toString() }super.updateCache(relativePathMap.keys.toList()) {newValueCompute(relativePathMap[it]!!)} - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/FileRevisionCache.kt at line 5
import com.github.jonathanxd.dracon.revision.PijulVcsFileRevisionimport com.github.jonathanxd.dracon.revision.loadStateInRevisionimport com.github.jonathanxd.dracon.i18n.DraconBundleimport com.github.jonathanxd.dracon.pijul.pijulimport com.github.jonathanxd.dracon.revision.* - edit in src/main/kotlin/com/github/jonathanxd/dracon/cache/FileRevisionCache.kt at line 10
import com.intellij.openapi.progress.ProgressIndicatorimport com.intellij.openapi.progress.forEachWithProgressimport com.intellij.openapi.progress.withPushPop - edit in src/main/kotlin/com/github/jonathanxd/dracon/cache/FileRevisionCache.kt at line 15
import java.nio.file.Path - edit in src/main/kotlin/com/github/jonathanxd/dracon/cache/FileRevisionCache.kt at line 17
import java.util.concurrent.Executorsimport java.util.concurrent.locks.ReentrantLock - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/FileRevisionCache.kt at line 19
class FileRevisionCache(val project: Project) {private val cache = DataCache<FileRevisionRef, ByteArray>(this.project, "file_revision")class FileRevisionCache(val project: Project) : CacheService<FileRevisionRef, ByteArray> {override val cache = DataCache<FileRevisionRef, ByteArray>(this.project, "file_revision")fun loadAsync(rev: PijulVcsFileRevision): CompletableFuture<ByteArray> =this.loadAsync(rev.filePath, rev.revision)fun loadAsync(rev: PijulContentRevision): CompletableFuture<ByteArray> =this.loadAsync(rev.filePath, rev.revision) - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/FileRevisionCache.kt at line 28
fun loadAsync(rev: PijulVcsFileRevision): CompletableFuture<ByteArray> {fun loadAsync(file: Path, rev: PijulRevisionNumber): CompletableFuture<ByteArray> { - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/FileRevisionCache.kt at line 30
val fileRev = FileRevisionRef(rev.filePath.toAbsolutePath().toString(), rev.revision.hash)val fileRev = FileRevisionRef(file.filePathAsString(), rev.hash) - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/FileRevisionCache.kt at line 34
rev.revision.hash,rev.hash, - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/FileRevisionCache.kt at line 37
rev.filePathfile - edit in src/main/kotlin/com/github/jonathanxd/dracon/cache/FileRevisionCache.kt at line 41
private fun Path.filePathAsString() = this.toAbsolutePath().toString()fun loadAndPrecacheRevisions(amount: Int, i: ProgressIndicator) {this.cache.lock()try {i.isIndeterminate = falseval root = project.service<PijulVcsContext>().rootval revs = pijul(project).allRevisions(project, root).result?.take(amount).orEmpty() - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/FileRevisionCache.kt at line 51
fun loadAsync(rev: PijulContentRevision): CompletableFuture<ByteArray> {val root = project.service<PijulVcsContext>().rootval fileRev = FileRevisionRef(rev.filePath.toAbsolutePath().toString(), rev.revision.hash)val states = i.withPushPop {i.text = DraconBundle.message("index.revision.loading.text")loadStateInEveryRevisionForAllFiles(revs.map { it.hash },project,root,i)}i.text2 = DraconBundle.message("index.item.description.finish.text")i.withPushPop {i.text = DraconBundle.message("index.revision.files.text")states.entries.forEachWithProgress(i) { (rev, stateMap), indic ->stateMap.entries.forEachWithProgress(indic) { (path, bytes), indicator2 ->indicator2.text2 =DraconBundle.message("index.revision.file.description.text", path.toString(), rev)val revRef = FileRevisionRef(path.filePathAsString(), rev)this.cache.updateCache(revRef) {bytes}}}} - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/FileRevisionCache.kt at line 81
return this.cache.queryOrLoadAsync(fileRev) {loadStateInRevision(rev.revision.hash,this.project,root,rev.filePath).toByteArray(Charsets.UTF_8)i.text2 = DraconBundle.message("index.item.description.finish.text")i.fraction = 1.0} finally {this.cache.unlock() - edit in src/main/kotlin/com/github/jonathanxd/dracon/cache/FileRevisionCache.kt at line 86
}fun invalidate() {this.cache.invalidate() - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/FileRevisionCache.kt at line 92
): Serializable[5.21421]) : Serializable - edit in src/main/kotlin/com/github/jonathanxd/dracon/cache/DataCache.kt at line 7
import java.io.Serializable - edit in src/main/kotlin/com/github/jonathanxd/dracon/cache/DataCache.kt at line 11
import java.time.Instant - edit in src/main/kotlin/com/github/jonathanxd/dracon/cache/DataCache.kt at line 18
/*** Denotes the current version of data cache, must be updated when data cache format changes.*/const val DATA_CACHE_VERSION: Long = 2 - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/DataCache.kt at line 25
class DataCache<K, V>(val project: Project,val name: String) {class DataCache<K: Any, V: Any>(val project: Project,val name: String) { - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/DataCache.kt at line 30
private val manager = DataCacheManager<K, V>(this.cacheFile)private val manager = DataCacheManager<K, CachedValue<V>>(this.cacheFile, DATA_CACHE_VERSION) - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/DataCache.kt at line 32
private val updateExecutor = Executors.newCachedThreadPool()private val updateExecutor = Executors.newFixedThreadPool(10) - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/DataCache.kt at line 34
private val inMemory = ConcurrentHashMap<K, V>()private val inMemory = ConcurrentHashMap<K, CachedValue<V>>() - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/DataCache.kt at line 64
val computeEntry = compute(key)val computeEntry = CachedValue(Instant.now(), compute(key)) - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/DataCache.kt at line 71
}}.value - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/DataCache.kt at line 91
this.inMemory[key] = iMapper(computeEntry!!)this.inMemory[key] = CachedValue(Instant.now(), iMapper(computeEntry!!)) - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/DataCache.kt at line 95
vMapper(this.inMemory[key]!!)vMapper(this.inMemory[key]!!.value) - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/DataCache.kt at line 104
return CompletableFuture.completedFuture(this.inMemory[key]!!)return CompletableFuture.completedFuture(this.inMemory[key]!!.value) - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/DataCache.kt at line 109
val computeEntry = compute(key)val computeEntry = CachedValue(Instant.now(), compute(key)) - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/DataCache.kt at line 116
}}.value - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/DataCache.kt at line 127
return CompletableFuture.completedFuture(vMapper(this.inMemory[key]!!))return CompletableFuture.completedFuture(vMapper(this.inMemory[key]!!.value)) - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/DataCache.kt at line 137
this.inMemory[key] = iMapper(computeEntry!!)this.inMemory[key] = CachedValue(Instant.now(), iMapper(computeEntry!!)) - edit in src/main/kotlin/com/github/jonathanxd/dracon/cache/DataCache.kt at line 148
/*** @see CacheService.invalidate*/ - edit in src/main/kotlin/com/github/jonathanxd/dracon/cache/DataCache.kt at line 161
/*** @see CacheService.invalidate*/fun invalidate(key: K) {this.lock.lock()try {this.inMemory.remove(key)this.manager.write(this.inMemory)} finally {this.lock.unlock();}}/*** @see CacheService.updateCache*/fun updateCache(key: K, newValueCompute: () -> V) {val instant = Instant.now()this.lock()try {val inMemoryValue = this.inMemory[key]if (inMemoryValue == null || inMemoryValue.instant.isBefore(instant)) {this.inMemory[key] = CachedValue(instant, newValueCompute())}} finally {this.unlock()}}/*** @see CacheService.updateCache*/fun updateCache(keys: List<K>, newValueCompute: (K) -> V) {val instant = Instant.now()this.lock()try {for (key in keys) {val inMemoryValue = this.inMemory[key]if (inMemoryValue == null || inMemoryValue.instant.isBefore(instant)) {this.inMemory[key] = CachedValue(instant, newValueCompute(key))}}} finally {this.unlock()}} - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/DataCache.kt at line 210
class DataCacheManager<K, V>(val path: Path) {class DataCacheManager<K, V>(val path: Path, val version: Long) { - replacement in src/main/kotlin/com/github/jonathanxd/dracon/cache/DataCache.kt at line 222
return reader.readObject() as Map<K, V>val version = reader.readLong()return if (version != version) {emptyMap()} else {reader.readObject() as Map<K, V>} - edit in src/main/kotlin/com/github/jonathanxd/dracon/cache/DataCache.kt at line 242
oos.writeLong(this.version) - file addition: CachedValue.kt[5.8571]
package com.github.jonathanxd.dracon.cacheimport java.io.Serializableimport java.time.Instantclass CachedValue<V>(val instant: Instant, val value: V): Serializable {companion object {const val serialVersionUID = 1L}} - file addition: CacheService.kt[5.8571]
package com.github.jonathanxd.dracon.cacheimport com.intellij.openapi.components.Serviceimport java.time.Instant/*** This is a base interface implemented by every [DataCache] service,* as [DataCache] is never used directly, an [IntelliJ Light Service][Service]* must be setup to interface a [DataCache] and classes that uses the cache.** This interface is for [Cache][DataCache] [Services][Service] which manages a single [DataCache][cache]* with a [key type][K] [K] and a [value type][V] [V]. If the service does manages more than one [DataCache][cache],* we **heavily recommend** you to split it into two different services which communicate with each other.*/interface CacheService<K: Any, V: Any> {val cache: DataCache<K, V>/*** Invalidates the [cache] that this service handles.** ## **Warning**** **This is only recommended when the cache is not working correctly, corrupted or an operation that changes* all the data that was previously cached takes in place.**** **This is not recommended to be called for little changes, such as the ones that applies to only one or `N{2,}` keys* because it slow down the perception of the Dracon performance, as it does need to cache all the data again, and as the* cache is backed by a temporary file in the seconday storage (not a memory one), it does depends on the I/O* overhead, which is good for NVMe storages and SATA 3 ones, but not for HDDs. Also some `pijul` operations are really* expensive, such as `pijul unrecord`, the Dracon Log Algorithm, Dracon File Status algorithms and Dracon Revision* load algorithm (backed by `pijul unrecord`), when the cache of these operations is invalidated, the overall* performance Dracon drops absurdly.**** @see DataCache*/fun invalidate() {this.cache.invalidate()}/*** Invalidates one key in [cache], this is a good way to invalidate data in cache (but not the best one), as it does not* cause all the cache to be recomputed, however, if you already know the new value for the cache, or a function* to compute it, use [updateCache] function.**/fun invalidate(key: K) {this.cache.invalidate(key)}/*** Updates the cache value of a [key] using the [newValueCompute]. This is the best way to update the cache data,* as it does provides either a lightweight function to compute the new cache value, or a constant computed value* that does not involve a new computation routine.** Please note that this function does not guarantee that the new computed value will be inserted into the cache,* because the cache could be updated between the time you change something that need to be reflected in the cache,* and the time request to update the key, if a cache recompute operation takes in this time between, the* service will ignore the provided [newValueCompute]. The up-to-date check is made using [CachedValue] container,* which holds the [Instant] which provides the time that an operation requested to update the cache (not the time the* update takes place). However this check do not guarantee that the cached value will be up-to-date, as we cannot guarantee* that the time the operation was requested matches the time the data was created.*/fun updateCache(key: K, newValueCompute: () -> V) {this.cache.updateCache(key, newValueCompute)}/*** Updates the cache value of multiple [keys] using the [newValueCompute]. This is the best way to update the cache data,* as it does provides either a lightweight function to compute the new cache value, or a constant computed value* that does not involve a new computation routine.** Please note that this function does not guarantee that the new computed value will be inserted into the cache,* because the cache could be updated between the time you change something that need to be reflected in the cache,* and the time request to update the key, if a cache recompute operation takes in this time between, the* service will ignore the provided [newValueCompute]. The up-to-date check is made using [CachedValue] container,* which holds the [Instant] which provides the time that an operation requested to update the cache (not the time the* update takes place). However this check do not guarantee that the cached value will be up-to-date, as we cannot guarantee* that the time the operation was requested matches the time the data was created.*/fun updateCache(keys: List<K>, newValueCompute: (K) -> V) {this.cache.updateCache(keys, newValueCompute)}} - file addition: annotation[5.107]
- file addition: NeedsCacheUpdate.kt[0.40561]
package com.github.jonathanxd.dracon.annotationimport com.github.jonathanxd.dracon.cache.CacheService/*** Signals that to an operation take effect in IntelliJ, the underling cache needs to be updated.*** There are two ways of updating the underling cache:** #### Execute [CacheService.invalidate]** It does cleanup the entire cache, which is only recommended for when the change does update everything that was cached,* or when the user requests to invalidate the cache, because the cache may be not working correctly or corrupt.**/annotation class NeedsCacheUpdate() - file move: activity → activity
- file addition: PijulIndexActivity.kt[4.3639]
package com.github.jonathanxd.dracon.activityimport com.github.jonathanxd.dracon.cache.FileRevisionCacheimport com.github.jonathanxd.dracon.i18n.DraconBundleimport com.intellij.openapi.components.serviceimport com.intellij.openapi.progress.ProgressIndicatorimport com.intellij.openapi.progress.Taskimport com.intellij.openapi.project.Projectimport com.intellij.openapi.startup.StartupActivityconst val PRE_INDEX_REVISION_AMOUNT = 30class PijulIndexActivity : StartupActivity.Background {override fun runActivity(project: Project) {object : Task.Backgroundable(project, DraconBundle.message("index.revision.text")) {override fun run(indicator: ProgressIndicator) {val fileRevisionCache = project.service<FileRevisionCache>()fileRevisionCache.loadAndPrecacheRevisions(PRE_INDEX_REVISION_AMOUNT, indicator)}}.queue()}} - replacement in src/main/kotlin/com/github/jonathanxd/dracon/actions/PijulInvalidateCaches.kt at line 13
import com.github.jonathanxd.dracon.cache.FileRevisionCacheimport com.github.jonathanxd.dracon.cache.FileStatusCacheimport com.github.jonathanxd.dracon.cache.PijulLogEntryCacheimport com.github.jonathanxd.dracon.cache.PijulLogEntryChangeCacheimport com.github.jonathanxd.dracon.cache.* - replacement in src/main/kotlin/com/github/jonathanxd/dracon/actions/PijulInvalidateCaches.kt at line 51
indicator.fraction = 0.25indicator.fraction = 0.20 - replacement in src/main/kotlin/com/github/jonathanxd/dracon/actions/PijulInvalidateCaches.kt at line 56
indicator.fraction = 0.50indicator.fraction = 0.40 - replacement in src/main/kotlin/com/github/jonathanxd/dracon/actions/PijulInvalidateCaches.kt at line 61
indicator.fraction = 0.75indicator.fraction = 0.60 - edit in src/main/kotlin/com/github/jonathanxd/dracon/actions/PijulInvalidateCaches.kt at line 66
indicator.fraction = 0.80val logRevisionCache = project.service<PijulLogRevisionCache>()indicator.text2 = DraconBundle.message("cache.invalidate.current.text", "pijul log entry revision cache")logRevisionCache.invalidate() - file addition: PijulIgnoreActionGroup.kt[5.18106]
package com.github.jonathanxd.dracon.actionsimport com.intellij.openapi.vcs.changes.ignore.actions.IgnoreFileActionGroupimport com.intellij.openapi.vcs.changes.ignore.lang.IgnoreFileTypeobject PijulIgnoreActionGroup : IgnoreFileActionGroup(IgnoreFileType.INSTANCE) - file addition: PijulAddToIgnore.kt[5.18106]
/*** 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.actionsimport com.github.jonathanxd.dracon.i18n.DraconBundleimport com.github.jonathanxd.dracon.pijul.NonZeroExitStatusCodeimport com.github.jonathanxd.dracon.pijul.Pijulimport com.github.jonathanxd.dracon.pijul.pijulimport com.github.jonathanxd.dracon.util.wrapInHmlimport com.github.jonathanxd.dracon.vcs.DraconVcsUtilimport com.github.jonathanxd.dracon.vcs.NotificationIdsimport com.github.jonathanxd.dracon.vfs.DraconVfsUtilimport com.intellij.openapi.actionSystem.AnActionEventimport com.intellij.openapi.actionSystem.CommonDataKeysimport com.intellij.openapi.fileChooser.FileChooserimport com.intellij.openapi.fileChooser.FileChooserDescriptorFactoryimport com.intellij.openapi.progress.ProgressIndicatorimport com.intellij.openapi.progress.Taskimport com.intellij.openapi.project.DumbAwareActionimport com.intellij.openapi.project.ProjectManagerimport com.intellij.openapi.ui.Messagesimport com.intellij.openapi.vcs.ProjectLevelVcsManagerimport com.intellij.openapi.vcs.VcsNotifierimport com.intellij.openapi.vcs.changes.VcsDirtyScopeManagerimport com.intellij.vcsUtil.VcsUtilclass PijulAddToIgnore: DumbAwareAction() {override fun actionPerformed(e: AnActionEvent) {val project = e.getData(CommonDataKeys.PROJECT) ?: ProjectManager.getInstance().defaultProjectval fcd = FileChooserDescriptorFactory.createSingleFileDescriptor()fcd.isShowFileSystemRoots = truefcd.title = DraconBundle.Init.titlefcd.description = DraconBundle.Init.descriptionfcd.isHideIgnored = falseval baseDir = e.getData(CommonDataKeys.VIRTUAL_FILE)?.let { if (it.isDirectory) null else it } ?: project.baseDirFileChooser.chooseFile(fcd, project, baseDir) { root ->if (Pijul.isUnderPijul(root)) {val dialog = Messages.showYesNoCancelDialog(project,DraconBundle.Init.alreadyUnderPijulForHtml(root.presentableUrl),DraconBundle.Init.title,Messages.getWarningIcon())if (dialog != Messages.YES) {return@chooseFile}}object : Task.Backgroundable(project, DraconBundle.Dracon.refreshing) {override fun run(indicator: ProgressIndicator) {indicator.isIndeterminate = trueval init = pijul(project).init(project, root)if (init.statusCode is NonZeroExitStatusCode) {VcsNotifier.getInstance(this.project).notifyError(NotificationIds.FAILED_TO_INIT,DraconBundle.Init.error,init.statusCode.message.wrapInHml(),true)}if (project.isDefault) {return}// Refresh VCS?DraconVcsUtil.refreshAfterInit(project, root)}}.queue()}}} - edit in src/main/kotlin/com/github/jonathanxd/dracon/actions/PijulAddExtension.kt at line 13
import com.github.jonathanxd.dracon.cache.CacheablePijulFileStatusimport com.github.jonathanxd.dracon.cache.FileStatusCacheimport com.github.jonathanxd.dracon.cache.toPijulimport com.github.jonathanxd.dracon.pijul.SuccessStatusCode - edit in src/main/kotlin/com/github/jonathanxd/dracon/actions/PijulAddExtension.kt at line 19
import com.intellij.openapi.components.service - edit in src/main/kotlin/com/github/jonathanxd/dracon/actions/PijulAddExtension.kt at line 26
import com.intellij.vcsUtil.VcsUtilimport java.nio.file.Paths - replacement in src/main/kotlin/com/github/jonathanxd/dracon/actions/PijulAddExtension.kt at line 44
pijul(project).add(project, vcsRoot, paths)val trackedFiles = pijul(project).trackedFiles(project, Paths.get(VcsUtil.getFilePath(vcsRoot).path))val add = pijul(project).add(project, vcsRoot, paths)if (add.statusCode is SuccessStatusCode) {val pathsAsNio = paths.map {Paths.get(it.path).toAbsolutePath()}.filter { trackedFiles.result == null || !trackedFiles.result.contains(it) }project.service<FileStatusCache>().updateCacheForPaths(pathsAsNio) {FileStatus.ADDED.toPijul()}} - replacement in README.md at line 13
- [ ] Support loading file changes- Partially supported as FileStatus depends on this.- [X] Support loading file changes- Supported, but does introduce overheads. Read **[file changes loading](#file-changes-loading-overhead)** section. - replacement in README.md at line 16
- Does not support amend.- Record text file opens in default editor instead of IntelliJ Editor.- [ ] Support amend.- ~~Record text file opens in default editor instead of IntelliJ Editor.~~- [X] Record text is opened in IntelliJ IDEA powered by [editor-server](https://crates.io/crates/editor-server) backend.- [X] File history support- [X] Allows users to compare between revisions- [X] Allows users to see affected files for any given revision. - edit in README.md at line 30
Dracon is in a heavily experimental state, and it depends on latest IDEA EAP build.### Pick a build - replacement in README.md at line 35
Dracon is in a heavily experimental state, and it depends on latest IDEA EAP build. First download an **experimental** or **nightly** build from [builds](https://nest.pijul.com/Jonathan/Dracon:main/MJDBCNFHSHAR4.BEAAA) directory (probably you will need to clone this repo to get the zip file), then go to IntelliJ IDEA Plugins section and click in the gear on the right side of *Installed tab* and select *Install plugin from Disk...* and select the downloaded Dracon *.zip*. Now you're ready to go.The easiest way is to pick an officially packaged version of Dracon which we periodically publish.First download an **experimental** or **nightly** build from [builds](https://nest.pijul.com/Jonathan/Dracon:main/MJDBCNFHSHAR4.BEAAA) directory (probably you will need to clone this repo to get the zip file), then go to IntelliJ IDEA Plugins section and click in the gear on the right side of *Installed tab* and select *Install plugin from Disk...* and select the downloaded Dracon *.zip*. Now you're ready to go. - edit in README.md at line 40
### Build on your ownFirst clone Dracon repository:```bashpijul clone https://nest.pijul.com/Jonathan/Dracon```Then create build and package the plugin using `buildPlugin` gradle task: - edit in README.md at line 52
For Unix:```bash./gradlew buildPlugin```For Windows:```batch.\gradlew.bat buildPlugin```The generated plugin file could be find in `build/distributions` path, the installation of the plugin `.zip` is exactly the same as for an officially made build: Go to IntelliJ IDEA Plugins section and click in the gear on the right side of *Installed* tab and select *Install plugin from Disk...* and select the generated Dracon *.zip*.### JetBrains Marketplace - replacement in README.md at line 68
Recently versions of Dracon requires [editor-server](https://crates.io/crates/editor-server) to be installed in order to work, the finalrelease version will come bundled with the [editor-server](https://crates.io/crates/editor-server).### DependenciesRecently versions of Dracon requires [editor-server](https://crates.io/crates/editor-server) to be installed in order to work, ~~the finalrelease version will come bundled with the [editor-server](https://crates.io/crates/editor-server).~~ The most recent version of Dracon does prompts for Pijul and Editor-Server download, as this requires Cargo in order to install dependencies if it is not installed, Dracon will prompt for Rustup and Cargo installation, it does the baby steps for installation, but you take the lead as soon as choices need to be made.## File Changes Loading OverheadPijul does not have an easy way to retrieve the state of a file in a given revision, in order to support this, Dracon creates a copy of the repository in a temporary directory and execute `pijul unrecord` against all revisions that happened after the given revision.For CoW based file systems, such as ZFS and Btrfs, this operation is very cheap, and as long as all the files are not modified when **pijul unrecord** changes, this overhead may not be perceptible. However, there are some cases when this overhead becomes very perceptible, for example, when the amount of revisions between the target revision (the revision who you want to see), and the current revision (the last recorded revision), are bigger.So, how much bigger is bigger enough to be perceptible? I'm not sure, I don't have enough samples to conclude the exact amount of changes that are needed in order to this operation overhead be perceptible, it also depends on the complexity of the entire operation, how many files changed between these revisions, the complexity of these changes, the performance of the secondary storage (Read/Write). I've been tested Dracon and made a bunch of performance improvements, such as caching, which improved the overall performance of revision loading and project loading.~~An NVMe SSD and a CoW file system alleviate this a bit, however I'm always working in strategies to improve the performance, however when Pijul provides a way to see the state of a file in a given revision, I will use it instead of the actual routine.~~In the most current versions, Dracon does a bunch of caching and preloads file revisions, also caching code has been the focus of the development now that Dracon is almost ready for a nightly release. However, there is room for improvements.~~Also, I'm currently improving the rollback algorithm to *unrecord* only revision which actually change the file, instead of all revisions between the actual revision (inclusively) and the target revision (exclusively) by looking at `pijul credit`~~Plans have changed, instead of only un-recording changes that `pijul credit` annotated, Dracon save the state of other files of a given revision, speeding things a bit and reducing the amount of `pijul unrecord` we execute (currently only for the caching).