feat(diff): Add the diff_history command (#97)

This new command is natively implemented by both the `codediff` and `diffview` backends allowing to easily navigate the changes between two revsets while diffing the. 

It also gives a new `:J diff_hisotyr` command that optionally takes a range of revsets formatted `<rev1>..<rev2>` otherwise it prompts the user for the range.
This commit is contained in:
Nicolas GB
2026-03-12 18:03:23 +01:00
committed by GitHub
parent ec44937e1b
commit 1c3d38a626
8 changed files with 184 additions and 3 deletions
+12 -1
View File
@@ -28,6 +28,7 @@ local utils = require("jj.utils")
---@field diff_current? fun(opts: jj.diff.current_opts)
---@field show_revision? fun(opts: jj.diff.revision_opts)
---@field diff_revisions? fun(opts: jj.diff.revisions_opts)
---@field diff_history_revisions? fun(opts: jj.diff.revisions_opts)
---@class jj.diff.config
---@field backend? jj.diff.backend
@@ -99,7 +100,7 @@ end
-----------------------------------------------------------------------
--- Single dispatcher (canonical entry point)
---@param kind "current"|"revision"|"revisions"
---@param kind "current"|"revision"|"revisions"|"history"
---@param opts table
function M.open(kind, opts)
opts = opts or {}
@@ -120,6 +121,10 @@ function M.open(kind, opts)
return backend.diff_revisions(opts)
end
return backends.native.diff_revisions(opts)
elseif kind == "history" then
if backend.diff_history_revisions then
return backend.diff_history_revisions(opts)
end
else
utils.notify("[Diff] unknown diff kind: " .. tostring(kind), vim.log.levels.ERROR)
end
@@ -143,6 +148,12 @@ function M.diff_revisions(opts)
return M.open("revisions", opts)
end
-- Diff between two revisions with history mode active
--- @param opts jj.diff.revisions_opts
function M.diff_history_revisions(opts)
return M.open("history", opts)
end
---
-----------------------------------------------------------------------
-- BACKWARDS COMPATIBLE API