-
Notifications
You must be signed in to change notification settings - Fork 349
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
conflicts: add "ui.conflict-marker-style" config #4897
Conversation
6bb9f91
to
3588eac
Compare
+1 for supporting the "snapshot" markers. |
3588eac
to
381aba9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't reviewd the last two commits, but I've read the commit message for them and it sounds like you didn't miss anything (in particular, it would have been easy to miss that we want support for parsing either style regardless of configured style).
6aed3c0
to
bfdf68b
Compare
Let me know when this is ready for review. (I don't think I get a notification when a PR is marked ready.) |
bfdf68b
to
c0181bd
Compare
4a03751
to
c1207f8
Compare
Ok, I think it's ready for review now! Let me know if I should split some of these commits into separate PRs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a clever approach, it's simpler than what I was thinking (allowing other conflict styles only in a jj file edit
command). I was worried for a bit that this would make #3975 worse, but I currently think that it's probably manageable and might be worth the complexity. I wrote down some related thoughts in case they spark anybody else's thinking.
da58564
to
bb19e68
Compare
323b1e0
to
7213011
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for this PR! I know a lot of people want this feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would split the merge-tools patches to separate PR because this PR is getting bigger.
7213011
to
6d643ce
Compare
45280c7
to
ceb25d7
Compare
ceb25d7
to
362d6f4
Compare
Adds a new "ui.conflict-marker-style" config option. The "diff" option is the default jj-style conflict markers with a snapshot and a series of diffs to apply to the snapshot. New conflict marker style options will be added in later commits. The majority of the changes in this commit are from passing the config option down to the code that materializes the conflicts. Example of "diff" conflict markers: ``` <<<<<<< Conflict 1 of 1 +++++++ Contents of side jj-vcs#1 fn example(word: String) { println!("word is {word}"); %%%%%%% Changes from base to side jj-vcs#2 -fn example(w: String) { +fn example(w: &str) { println!("word is {w}"); >>>>>>> Conflict 1 of 1 ends } ```
This makes the code a bit easier to follow in my opinion.
This will make it easier to add separate logic for "snapshot" style conflict markers in the next commit.
Adds a new "snapshot" conflict marker style which returns a series of snapshots, similar to Git's "diff3" conflict style. The "snapshot" option uses a subset of the conflict hunk headers as the "diff" option (it just doesn't use "%%%%%%%"), meaning that the two options are trivially compatible with each other (i.e. a file materialized with "snapshot" can be parsed with "diff" and vice versa). Example of "snapshot" conflict markers: ``` <<<<<<< Conflict 1 of 1 +++++++ Contents of side jj-vcs#1 fn example(word: String) { println!("word is {word}"); ------- Contents of base fn example(w: String) { println!("word is {w}"); +++++++ Contents of side jj-vcs#2 fn example(w: &str) { println!("word is {w}"); >>>>>>> Conflict 1 of 1 ends } ```
This will make it easier to add a second code path for Git-style conflicts in a later commit.
This was already possible using `merge.iter().as_slice()`, but I think this is cleaner.
Adds a new "git" conflict marker style option. This option matches Git's "diff3" conflict style, allowing these conflicts to be parsed by some external tools that don't support JJ-style conflicts. If a conflict has more than 2 sides, then it falls back to the similar "snapshot" conflict marker style. The conflict parsing code now supports parsing Git-style conflict markers in addition to the normal JJ-style conflict markers, regardless of the conflict marker style setting. This has the benefit of allowing the user to switch the conflict marker style while they already have conflicts checked out, and their old conflicts will still be parsed correctly. Example of "git" conflict markers: ``` <<<<<<< Side jj-vcs#1 (Conflict 1 of 1) fn example(word: String) { println!("word is {word}"); ||||||| Base fn example(w: String) { println!("word is {w}"); ======= fn example(w: &str) { println!("word is {w}"); >>>>>>> Side jj-vcs#2 (Conflict 1 of 1 ends) } ```
The current docs for conflict markers start out by introducing Git "diff3" conflict markers, and then discussing how Jujutsu's conflict markers are different from Git's. I don't think this is the best way to explain it, because it requires the reader to first understand Git's conflict markers before they go on to learn Jujutsu's conflict markers. Instead, I think it's better to explain the conflict markers from scratch with a more detailed example so that we don't assume any particular knowledge of Git. This structure also works better with the new config option, since we can talk about the default option first, and then go on to explain alternatives later.
362d6f4
to
9f69077
Compare
Resolves #823.
Adds support for "diff" (current default), "snapshot", and "git-diff3" (falls back to "diff" if more than 2 sides) options.
Example of "diff"
Example of "snapshot"
Example of "git"
Checklist
If applicable:
CHANGELOG.md