feat(jj): parse jj-style conflict markers in parse_conflicts - #308
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends M.parse_conflicts in lua/diffview/vcs/utils.lua to recognize Jujutsu (jj) conflict markers in addition to the existing git diff3 markers, so that diffview's marker-based conflict actions (choose ours/base/theirs, navigate conflicts) work in jj repositories using the default ui.conflict-marker-style = "diff" and "snapshot" styles. Previously only git-style markers (including jj's "git" style) were understood.
The implementation adds a self-contained jj sub-parser that is tried before the git state machine, gated by a forward "peek" so that a git conflict whose branch label merely starts with conflict is still handled by the git path. jj regions are projected onto the existing ours/base/theirs model; 3+ sided or otherwise unrepresentable regions are skipped. The existing git parsing path is left behavior-unchanged, and the cursor-tracking logic is refactored into a shared register helper reused by both paths.
Changes:
- Add jj marker patterns plus
looks_like_jj_region(disambiguation peek) andparse_jj_region(assembles aConflictRegionfrom%%%%%%%/+++++++/-------sub-blocks), and integrate them into theparse_conflictsloop via askip_untilmechanism. - Extract cursor/index bookkeeping into a
registerhelper shared by the githandlepath and the new jj path. - Add a comprehensive
parse_conflicts_spec.luaand update the help doc note to reflect jj marker-style support.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
lua/diffview/vcs/utils.lua |
Adds jj marker patterns, looks_like_jj_region/parse_jj_region, a shared register helper, and loop integration to parse jj conflict regions. |
lua/diffview/tests/functional/parse_conflicts_spec.lua |
New unit tests covering git diff3, jj diff/snapshot styles, N-sided skipping, and mixed back-to-back regions. |
doc/diffview.txt |
Updates the Jujutsu note to state all three marker styles work for 2-sided conflicts and 3+ sided ones are skipped. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
No description provided.