Skip to content

feat(jj): support multi-file merge via DiffviewOpen - #288

Merged
dlyongemallo merged 1 commit into
mainfrom
267-jj_save_and_advance
Aug 20, 2026
Merged

feat(jj): support multi-file merge via DiffviewOpen#288
dlyongemallo merged 1 commit into
mainfrom
267-jj_save_and_advance

Conversation

@dlyongemallo

Copy link
Copy Markdown
Owner

Proposed alternative to using DiffviewMergeFiles directly as a jj merge tool.

Relates to #267.

@dlyongemallo
dlyongemallo force-pushed the 267-jj_save_and_advance branch 2 times, most recently from bd84d04 to 919cdbd Compare July 9, 2026 09:39
@dlyongemallo
dlyongemallo force-pushed the 267-jj_save_and_advance branch 2 times, most recently from e1a88f6 to 4a39114 Compare August 19, 2026 21:08
@dlyongemallo
dlyongemallo requested a balanced review from Copilot August 19, 2026 21:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 gate toggle_stage_entry via a new stage_or_resolve action tag plus a content-based resolve path in the diff listeners.
  • Rework jj _query_merge_context to anchor on the nearest ancestor merge (latest(ancestors(@) & merges(), 1)) and base at fork_point(<merge>-), and wrap parse_revs @- in latest(...) for merge-safe parent resolution.
  • Update the auto-close policy to gate index-less adapters on a had_conflicts latch, 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.

@dlyongemallo dlyongemallo changed the title feat(jj): make s/- save and advance in merge views feat(jj): support multi-file merge via DiffviewOpen Aug 20, 2026
@dlyongemallo
dlyongemallo force-pushed the 267-jj_save_and_advance branch from 4a39114 to ad1f415 Compare August 20, 2026 06:58
@dlyongemallo
dlyongemallo merged commit 460b96c into main Aug 20, 2026
8 checks passed
@dlyongemallo
dlyongemallo deleted the 267-jj_save_and_advance branch August 20, 2026 06:59
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.

2 participants