This repository was archived by the owner on Sep 30, 2024. It is now read-only.
migration: Add stitch utilities#36319
Merged
Merged
Conversation
737fe75 to
681ab66
Compare
This was referenced Jun 30, 2022
cad8a6f to
d5b6dfd
Compare
285d578 to
ae36092
Compare
This was referenced Jul 20, 2022
35d9b80 to
b5cb02c
Compare
1abd6bc to
337dfcb
Compare
This is the follow up/improved version of #39116 This commit adds support for syntax highlighting from lsif/scip data that is returned for some languages. Updating the backend to return lsif/scip data for every language is done in a separate PR (#39264), but this PR does not depend on it (if treesitter highlighting is not configured there simply won't be any highlighting). Syntax highlighting is done by an extension that takes the JSON encoded scip data and converts it to something CodeMirror can understand. Decorations are only generated for the lines that are currently rendered. I originally converted line/column ranges to document-offset ranges and used binary search to find the relevant ranges for the currently rendered lines. However the overhead of doing the line/column -> offset conversion was noticeable for large documents, but especially unnecessary for those because only a small subset of lines would be visible. Then I changed to an approach that would use the data sent from the server as is (to avoid creating additional objects in memory and GC-ing the JSON decoded data) and only add a simple line index. The conversion from line/column to document offset is now delayed until the moment the decorations are created. This only works under the assumption that the server sends back the ranges order and without overlap. Some of the changes I made (e.g. exporting the replaceValue function) are not relevant anymore for the final version, but I'll leave them in for completeness. Other auxiliary changes in this commit: Changed the base CodeMirror hook to allow for "manually" dispatching a transaction to update the value. Without this we would trigger at least two transactions when loading a file: One for updating the document and one for updating the syntax highlighting. Now we can do both in a single transaction. Added a folder for CodeMirror blob extensions and moved the line numbers extension there as well.
Contributor
|
Codenotify: Notifying subscribers in OWNERS files for diff 1da629b...9dbe187.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds utilities to combine the migration graphs over several releases of Sourcegraph so that we can perform upgrades over multiple versions where a migration file squash has occurred. Fixes #38045.
The new main method
StitchDefinitionscalculates a stitched migration graph for tests but is not yet utilized. Future PRs will bundle these results into artifacts that can be used to upgrade on-prem.How to review - by file, in order:
stitch_test.go: Start with the test case to see the current coverage.There's currently only basic validation (is the graph valid), but we should also add testing to ensure the migration graph can run correctly against a live database in a subsequent PR.We validate the graph and the result of an upgrade from 3.29 -> 3.42.git.go: Read these leaf functions that interact with the enclosing git clone to prep for the next two files.reader.go: Read this file which reads "raw migrations" from the enclosing git clone.rewriter.go: This is a wrapper around reading raw migrations (above) that does some specific rewrites to handle changes to migration definitions over time. Pay attention to details within this file, but forget them once moving on in the review. This file is how we support migrations defined back to 3.29.0 for all three schemas.stitch.go: Read top-to-bottom with code flow to finish off how migrations are merged together.Test plan
New unit tests introduced in this PR.