Skip to content

feat: add VCS support for Jujutsu, Sapling, Perforce#22

Merged
dlyongemallo merged 9 commits intomainfrom
add_support_for_other_vcs
Feb 26, 2026
Merged

feat: add VCS support for Jujutsu, Sapling, Perforce#22
dlyongemallo merged 9 commits intomainfrom
add_support_for_other_vcs

Conversation

@dlyongemallo
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings February 26, 2026 08:33
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds support for three new version control systems to diffview.nvim: Jujutsu (jj), Sapling, and Perforce (p4). The PR also includes important fixes and improvements to the existing codebase.

Changes:

  • Adds full Jujutsu adapter with support for :DiffviewOpen (file history not yet implemented)
  • Adds Sapling detection through the existing Mercurial adapter with automatic version check bypass
  • Adds experimental Perforce adapter with support for both diff views and file history
  • Fixes Git adapter to handle MSYS2/Cygwin Unix-style paths on Windows
  • Adds refresh mechanism for VCS adapters to handle mutable revision references
  • Optimizes keymap handling by caching buffer keymaps per mode
  • Fixes nil access bug in Mercurial adapter's conflict handling

Reviewed changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
lua/diffview/vcs/init.lua Registers new JjAdapter and P4Adapter alongside existing adapters
lua/diffview/vcs/adapters/jj/init.lua Complete Jujutsu adapter implementation with bookmark support and revset handling
lua/diffview/vcs/adapters/jj/rev.lua Jujutsu revision class extending base Rev
lua/diffview/vcs/adapters/p4/init.lua Perforce adapter with client root detection, file history, and diff support
lua/diffview/vcs/adapters/p4/rev.lua Perforce revision class handling changelist and revision specifiers
lua/diffview/vcs/adapters/p4/commit.lua Perforce commit parsing from p4 describe output
lua/diffview/vcs/adapters/hg/init.lua Adds Sapling detection and fixes conflict file_info nil access
lua/diffview/vcs/adapters/git/init.lua Adds Cygwin path normalization for Windows compatibility
lua/diffview/vcs/adapter.lua Adds refresh_revs, force_entry_refresh_on_noop, and on_local_buffer_reused methods
lua/diffview/vcs/file.lua Optimizes keymap saving by caching per-mode keymap lookups
lua/diffview/scene/file_entry.lua Adds force parameter to destroy method for proper cleanup
lua/diffview/scene/views/diff/diff_view.lua Implements rev refresh and entry replacement logic for mutable revs
lua/diffview/tests/functional/jj_adapter_spec.lua Comprehensive test coverage for Jujutsu adapter
lua/diffview/tests/functional/file_entry_spec.lua Tests for force flag propagation in destroy
lua/diffview/config.lua Adds jj_cmd and p4_cmd configuration options
lua/diffview/health.lua Adds health checks for new adapters
doc/* Documentation updates for new VCS support
README.md Updates requirements and usage examples for new adapters
Comments suppressed due to low confidence (3)

lua/diffview/vcs/adapters/p4/commit.lua:68

  • Inconsistent whitespace: Line 68 has an extra leading space before if time_unix then. This should be aligned with line 67 to maintain consistent indentation throughout the file.
         if time_unix then

lua/diffview/vcs/adapters/p4/commit.lua:32

  • Unused local variable: The variable current_file_diff is declared but never used. It should be removed to avoid clutter and potential confusion.
    local current_file_diff = {}

lua/diffview/vcs/adapters/p4/commit.lua:34

  • Unused loop variable: The variable i is declared in the for loop but never used within the loop body. Consider using for _, line in ipairs(output_lines) do to indicate the index is intentionally unused.
    for i, line in ipairs(output_lines) do

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

dlyongemallo and others added 9 commits February 26, 2026 10:07
Cherry-picked from skt041959/diffview.nvim (commit 0aae525).
Cherry-picked from jrodal98/diffview.nvim (commit 8957807).
Add a full JjAdapter for DiffviewOpen with rev parsing, bookmark
handling, main→master fallback, merge-base resolution via triple-dot,
refresh-revs support, and working-tree diff content refresh.

Includes documentation, tests, and the force parameter on
FileEntry:destroy() needed by the replace-noop refresh path.

Cherry-picked from vramana/diffview.nvim (commits 600a120..fda5b1a).
Reorder adapter probing so GitAdapter is tried before JjAdapter,
avoiding unnecessary `jj root` calls in plain git repos.

Revert generic file.lua changes (bufload/checktime, is_loaded→is_valid)
and replace them with a jj-specific on_local_buffer_reused() hook, so
existing Git/Hg behaviour is unchanged.
Initialise the file_info entry before setting status when the file
state is 'u' (unresolved), preventing a nil index error in
tracked_files().

Cherry-picked from cavanaug/diffview.nvim (commit 2711fc7).
When running native Windows Neovim with Cygwin-based git, commands
like `rev-parse --show-toplevel` return Unix-style paths (e.g.
`/c/Users/...`) that Neovim cannot use. Detect this case and convert
via `cygpath --absolute --windows`. Only fires when `has('win32')` is
true and the path starts with `/`, so Linux/macOS users are unaffected.

Based on softvisio/diffview.nvim (commits a67c42d, 06232a8) and
upstream PR sindrets#574, with modifications: use `vim.trim()` instead of
manual newline stripping, add type annotations, use double quotes.
Allows users to specify which VCS adapter should be tried first when
detecting repositories, useful for colocated jj/git repos where both
adapters would match.
* Restructure requirements into plugin vs VCS sections with supported
  VCS list and version constraints.
* Add p4_cmd to example config.
* Add VCS Adapter Notes section (Jujutsu limitations, Sapling config,
  Perforce experimental status).
* Add MSYS2/Cygwin tip for Windows users.
@dlyongemallo dlyongemallo force-pushed the add_support_for_other_vcs branch from 20f1396 to 651d82c Compare February 26, 2026 09:19
@dlyongemallo dlyongemallo merged commit ccffbb9 into main Feb 26, 2026
2 checks passed
@dlyongemallo dlyongemallo deleted the add_support_for_other_vcs branch February 26, 2026 09:24
@rmccord7
Copy link

Perforce loads the file tab, but fails to actually load the diff. Looking at the logs it looks like most commands are failing because they are appending #1#head to the file as the revision specifier. Only one of these should be needed. The p4 server is returning an error because it does not understand the revision specifier. I use perforce for work so sharing the log would include proprietary file information.

@dlyongemallo
Copy link
Owner Author

@rmccord7 Thanks for the report. I'm looking into it. Unfortunately, I don't use perforce myself but I'll set up a dummy installation for testing this.

@dlyongemallo
Copy link
Owner Author

I think #38 should fix this.

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.

8 participants