feat(jj): support multi-file merge via DiffviewOpen - #288
Conversation
bd84d04 to
919cdbd
Compare
e1a88f6 to
4a39114
Compare
There was a problem hiding this comment.
Pull request overview
This PR implements the feature requested in issue #267: using jj (Jujutsu) as an interactive merge tool inside diffview. Because jj has no staging index, the existing s/- (toggle_stage_entry) staging action is repurposed on jj conflict views to "save the current MERGED buffer and advance to the next conflict," with auto_close_on_empty closing the view after the final resolution. To support this, a new adapter capability has_staging() is introduced and used to branch action-applicability and auto-close policy between staging adapters (git/hg/p4) and index-less ones (jj). The jj merge-context query is also hardened to locate the nearest ancestor merge, so propagated conflicts (where @ is a linear descendant of a conflicted merge) resolve correctly.
Changes:
- Add
VCSAdapter:has_staging()(base:true; jj:false) and gatetoggle_stage_entryvia a newstage_or_resolveaction tag plus a content-based resolve path in the diff listeners. - Rework
jj_query_merge_contextto anchor on the nearest ancestor merge (latest(ancestors(@) & merges(), 1)) and base atfork_point(<merge>-), and wrapparse_revs@-inlatest(...)for merge-safe parent resolution. - Update the auto-close policy to gate index-less adapters on a
had_conflictslatch, plus docs, keymap descriptions, and unit/functional tests.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
lua/diffview/vcs/adapters/jj/init.lua |
Merge-safe parse_revs, nearest-ancestor-merge context query, and has_staging() override returning false. |
lua/diffview/vcs/adapter.lua |
New base has_staging() capability method defaulting to true. |
lua/diffview/actions.lua |
New stage_or_resolve action tag and applicability logic branching on has_staging(). |
lua/diffview/scene/views/diff/listeners.lua |
Content-based conflict resolve/advance path and had_conflicts-gated auto-close. |
lua/diffview/scene/views/standard/standard_view.lua |
set_file_in_flight() accessor so auto-close can defer teardown. |
lua/diffview/config.lua, doc/diffview.txt, doc/diffview_defaults.txt |
Keymap-description and help updates for the jj save-and-advance behavior. |
lua/diffview/tests/functional/* |
New jj_save_and_advance_spec.lua and updates to actions/adapter/diff_view specs. |
A note for the author (outside the diff, so not filed as an inline comment): doc/diffview_changelog.txt:35-37 still states that staging actions including s are "no-ops in jj." That claim is now inaccurate for conflict views, and the changelog's own policy is to list notable feature additions — consider updating it.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
s/- save and advance in merge viewsDiffviewOpen
4a39114 to
ad1f415
Compare
Proposed alternative to using
DiffviewMergeFilesdirectly as ajjmerge tool.Relates to #267.