Skip to content

Conversation

scott2000
Copy link
Contributor

@scott2000 scott2000 commented Dec 25, 2024

Fixes #3968. Alternative to #5181 and #4088.

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added tests to cover my changes

@scott2000
Copy link
Contributor Author

One possible issue with this approach is that some conflicts become unreadable. For instance, a conflict with a base of base, a left side of left, and a right side of base\n would be rendered as:

<<<<<<< Conflict 1 of 1
+++++++ Contents of side #1
left
%%%%%%% Changes from base to side #2
 base
>>>>>>> Conflict 1 of 1 ends

@yuja
Copy link
Contributor

yuja commented Dec 25, 2024

One possible issue with this approach is that some conflicts become unreadable. For instance, a conflict with a base of base, a left side of left, and a right side of base\n

I think base and base\n can still be rendered as different contents (though these two are visually identical.) Maybe we can add some comment to the marker description?

@scott2000 scott2000 force-pushed the conflict-missing-newline-alternative branch from f900119 to 6a87871 Compare December 25, 2024 18:05
@scott2000
Copy link
Contributor Author

Ok, I updated it so that it would render as this:

<<<<<<< Conflict 1 of 1
+++++++ Contents of side #1 [noeol]
left
%%%%%%% Changes from base to side #2 [-noeol]
 base
>>>>>>> Conflict 1 of 1 ends

@scott2000 scott2000 force-pushed the conflict-missing-newline-alternative branch 4 times, most recently from d5ea5ea to e0ee931 Compare December 26, 2024 17:27
@scott2000 scott2000 force-pushed the conflict-missing-newline-alternative branch from e0ee931 to 9a636e0 Compare January 2, 2025 14:29
@scott2000 scott2000 force-pushed the conflict-missing-newline-alternative branch from 9a636e0 to f1bedc4 Compare January 16, 2025 03:32
@scott2000 scott2000 force-pushed the conflict-missing-newline-alternative branch from f1bedc4 to 1f22232 Compare January 25, 2025 00:54
@scott2000
Copy link
Contributor Author

I'll mark this as ready for review since there hasn't been any more discussion, and I think this is the simplest solution.

@scott2000 scott2000 marked this pull request as ready for review January 25, 2025 15:18
Copy link
Contributor

@yuja yuja left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks!

@scott2000 scott2000 force-pushed the conflict-missing-newline-alternative branch from 1f22232 to 3f805a7 Compare January 26, 2025 15:36
File conflicts have been simplified during materialization since 0.19.0,
so it should be safe to remove support for unsimplified conflicts now.
This will make implementing the next commit easier, since it won't have
to support unsimplified conflicts.
A missing newline would cause the following conflict markers to become
invalid when materializing the conflict, so we add a newline to prevent
this from happening. When parsing, if we parsed a conflict at the end of
the file which ended in a newline, we can check whether the file
actually did end in a newline, and then remove the newline if it didn't.
This isn't strictly necessary since it doesn't affect parsing, but it
should make it more understandable for the user.
@scott2000 scott2000 force-pushed the conflict-missing-newline-alternative branch from 3f805a7 to 34ba794 Compare January 26, 2025 17:40
@scott2000 scott2000 added this pull request to the merge queue Jan 27, 2025
Merged via the queue into jj-vcs:main with commit 66faeb4 Jan 27, 2025
19 checks passed
@scott2000 scott2000 deleted the conflict-missing-newline-alternative branch January 27, 2025 23:13
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.

Conflicts at the end of files that don't end in a newline are not materialized correctly
2 participants