Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Definition Diff machinery #4766

Merged
merged 21 commits into from May 19, 2024
Merged

Definition Diff machinery #4766

merged 21 commits into from May 19, 2024

Conversation

ChrisPenner
Copy link
Contributor

Overview

We've long wanted to be able to diff definitions against each other.

Adding this machinery here so it can be shared between Share and UCM; but initial plan is to implement Contribution diffs first, then probably add them to Unison Local.

Implementation notes

Uses the Haskell Diff library to compute a diff over syntax text. This means we diff definitions at the semantic token level rather than just over plain-text, which has the benefit that we can still generate links, hovers, cool colors, etc. in the diffs when rendered in the browser.

It also allows us to easily detect and special-case:

  • When a name changed, but the hash didn't
  • When a hash changed, but the name didn't

We may still want full tree-based structural diffing, but I suspect this form of smart diff will last us a long time.

Test coverage

I have some transcript tests in Share, but this format is still experimental (I'm planning on shipping a version of this for Simon to play with, then will tweak as needed). It doesn't affect any existing UCM behaviour or features, nor is this change observable from the CLI at all.

Loose ends

We need a UI for it! Coming soon™

@ChrisPenner ChrisPenner marked this pull request as ready for review April 23, 2024 16:31
@aryairani
Copy link
Contributor

aryairani commented Apr 25, 2024

@ChrisPenner Sweet!

@aryairani
Copy link
Contributor

@ChrisPenner Are there some tests and/or demonstrations we can do on this side?

@ChrisPenner
Copy link
Contributor Author

ChrisPenner commented May 17, 2024

@aryairani Okay I added the actual Unison Local API and some transcripts for this in #4964 , let me know if that helps, or if there's anything else we need to get this merged in 🙌🏼

aryairani
aryairani previously approved these changes May 17, 2024
Copy link
Contributor

@aryairani aryairani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chris and I talked through the testing strategy and landed on a combination of

  • it's not very practical to demo in the unison repo
  • there are transcript tests on the Share side (and also for Unison Local now, with Unison local Definition Diffs API #4964), but the output is hard for a human to interpret, so we kind of need a UI to help with that; the format may also change based on newly discovered requirements during development of the UI
  • we could create a ucm debug command to render diffs (and we may still end up wanting to do this), but it would be easiest for it to use colors (vs additional characters) to display diffs, and the colors wouldn't show up in transcripts, so we would be looking at test screenshots at best.
    • side note: a transcript runner that produced HTML output sounds awesome imo discussed this and decided it didn't sound awesome
  • the actual diffing is done in the Diff library https://hackage.haskell.org/package/Diff

@aryairani aryairani dismissed their stale review May 18, 2024 15:44

transcript output mismatch

@aryairani aryairani merged commit 0e617da into trunk May 19, 2024
19 checks passed
@aryairani aryairani deleted the cp/definition-diffs branch May 19, 2024 03:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants