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

Proof of concept: structured diff of conflicted commits #4251

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Commits on Sep 16, 2024

  1. lib merge: extract get_simplified_mapping and co.

    These will be used for diffs of Merge-s.
    
    This also refactors one of the less important tests. I did it mostly automatically with `ast-grep` (which I don't necessarily recommend), but we could also just delete this test I think.
    ilyagr committed Sep 16, 2024
    Configuration menu
    Copy the full SHA
    226ce13 View commit details
    Browse the repository at this point in the history
  2. lib get_simplified_mapping: change algorithm slightly

    This reorders the result slightly and makes it easier to generalize this to work on diffs of merges (where there is the same number of adds and removes).
    ilyagr committed Sep 16, 2024
    Configuration menu
    Copy the full SHA
    db2807c View commit details
    Browse the repository at this point in the history
  3. tmp: test changes

    ilyagr committed Sep 16, 2024
    Configuration menu
    Copy the full SHA
    8f3c51f View commit details
    Browse the repository at this point in the history
  4. lib merge: add DiffOfMerge type

    This represents a diff of two merges, up to reordering and cancelling
    out of terms. It can also be thought of as a stack of `n` diffs.
    
    This type is not very suitable for presenting to the user (since it
    loses information they might want to see), but is very natural from the
    perspective of conflict theory.
    ilyagr committed Sep 16, 2024
    Configuration menu
    Copy the full SHA
    a1286f3 View commit details
    Browse the repository at this point in the history
  5. lib merge: function to optimize diffs of merges wrt a distance func…

    …tion
    
    For textual conflicts, the distance function will be the size of the diff between two chunks of text.
    ilyagr committed Sep 16, 2024
    Configuration menu
    Copy the full SHA
    f67b150 View commit details
    Browse the repository at this point in the history
  6. lib merge: the key explain_diff_of_merges function and data struc…

    …ture
    
    This turns two Merge-s into an object that represents a way to present their difference to the user, in the form of `Vec<DiffExplanationAtom>`.
    
    `DiffExplanationAtom` is the key structure for the data model of differences between diffs.
    
    The algorithm is inefficient and far from perfect, for now my focus is on the data model.
    ilyagr committed Sep 16, 2024
    Configuration menu
    Copy the full SHA
    34003a9 View commit details
    Browse the repository at this point in the history
  7. lib file: Refactor merge of file hunks

    The goal here is to create a single operation to split a conflicted file text into a sequence of (potentially conflicted) hunks, both for regular conflicts and conflict diffs.
    
    The new algorithm is not efficient and I'm guessing an algorithm that gives better results (more logical hunks) is possilbe.
    
    We may want to instead keep the conflicts and conflict diff code path separate until the algorithm improves, let me know.
    ilyagr committed Sep 16, 2024
    Configuration menu
    Copy the full SHA
    e5262d8 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    fe554c5 View commit details
    Browse the repository at this point in the history
  9. cli diff-util: implement diff --structured-conflicts

    This works with all the places diffs are shown, e.g. `jj diff`, `jj log -p`, `jj interdiff`, etc.
    ilyagr committed Sep 16, 2024
    Configuration menu
    Copy the full SHA
    173623b View commit details
    Browse the repository at this point in the history
  10. indent added/removed diffs with +| or -|

    I initially tried just `+` and `-`, but that seemed confusing. The color helps, but I think this is ~understandable either way
    ilyagr committed Sep 16, 2024
    Configuration menu
    Copy the full SHA
    aa4d58e View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    ef9952c View commit details
    Browse the repository at this point in the history
  12. Show simple conflicts simply

    ilyagr committed Sep 16, 2024
    Configuration menu
    Copy the full SHA
    377ae1c View commit details
    Browse the repository at this point in the history
  13. Omit trivial diffs

    ilyagr committed Sep 16, 2024
    Configuration menu
    Copy the full SHA
    e5ed546 View commit details
    Browse the repository at this point in the history