Skip to content

Commit

Permalink
conflicts: escape conflict markers by making them longer
Browse files Browse the repository at this point in the history
If a file contains lines which look like conflict markers, then we need
to make the real conflict markers longer so that the materialized
conflicts can be parsed unambiguously.

When parsing the conflict, we require that the conflict markers in the
file are at least as long as the materialized conflict markers, and we
only parse the longest conflict markers in the file.

For instance, if we have a file explaining the differences between
Jujutsu's conflict markers and Git's conflict markers, it could produce
a conflict with long markers like this:

```
<<<<<<<<<<< Conflict 1 of 1
%%%%%%%%%%% Changes from base to side jj-vcs#1
 Jujutsu uses different conflict markers than Git, which just shows the
-sides of a conflict without a diff.
+sides of a conflict without a diff:
+
+<<<<<<<
+left
+|||||||
+base
+=======
+right
+>>>>>>>
+++++++++++ Contents of side jj-vcs#2
Jujutsu uses different conflict markers than Git:

<<<<<<<
%%%%%%%
-base
+left
+++++++
right
>>>>>>>
>>>>>>>>>>> Conflict 1 of 1 ends
```
  • Loading branch information
scott2000 committed Nov 26, 2024
1 parent 17576d1 commit d52c661
Show file tree
Hide file tree
Showing 3 changed files with 398 additions and 99 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
* New `merge-tools.<TOOL>.conflict-marker-style` config option to override the
conflict marker style used for a specific merge tool.

* Conflict markers are now allowed to be longer than 7 characters, allowing
conflicts to be materialized and parsed correctly in files which already
contain lines which look like conflict markers.

* `jj simplify-parents` now supports configuring the default revset when no
`--source` or `--revisions` arguments are provided with the
`revsets.simplify-parents` config.
Expand Down
Loading

0 comments on commit d52c661

Please sign in to comment.