From d3574092682b12f55fad57e88525f0fa8baed56f Mon Sep 17 00:00:00 2001 From: NicolasGB Date: Thu, 12 Mar 2026 16:54:22 +0100 Subject: [PATCH] feat(log): Add `change_revset` keybind to change the current log revset being displayed in the log command --- README.md | 12 +++++++++++- lua/jj/cmd/init.lua | 2 ++ lua/jj/cmd/log.lua | 14 ++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a169596..c873709 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ - [View change summary from the log buffer](#view-change-summary-from-the-log-buffer) - [Diff any change](#diff-any-change) - [Diff revision history](#diff-revision-history) + - [Change the log revset from the log buffer](#change-the-log-revset-from-the-log-buffer) - [Describe a change](#describe-a-change) - [Edit changes](#edit-changes) - [Create new changes from the log buffer](#create-new-changes-from-the-log-buffer) @@ -59,7 +60,7 @@ - First class citizens with ui integration - `describe` / `desc` - Set change descriptions with a Git-style commit message editor - `status` / `st` - Show repository status - - `log` - Display log history with configurable options + - `log` - Display log history with configurable options and change the displayed revset from the log buffer - `diff` - Show changes with optional filtering by current file - `new` - Create a new change with optional parent selection - `edit` - Edit a change @@ -122,6 +123,14 @@ You can now open a history-aware diff between two revisions: This is useful when you want to inspect the evolution of a stack or compare a revision range with commit history preserved instead of showing a single plain diff. +### Change the log revset from the log buffer + +You can change which revset the log buffer is displaying without closing and reopening it: + +- `` - Prompt for a new revset and reload the log buffer with it + +This is useful for quickly narrowing the log to something like `main::@`, `mutable()`, or any other revset while staying in the same log view. + ### Describe a change You can describe any change directly from the log buffer: @@ -492,6 +501,7 @@ The plugin also provides `:Jdiff`, `:Jvdiff`, and `:Jhdiff` commands for diffing quick_squash = "", -- Quick squash revision under cursor into its parent (ignore immutability) split = "", -- Split the revision under cursor history = "", -- Show a history-aware diff for the selected revision range + change_revset = "", -- Change the revset(s) being viewed in the log buffer tag_create = "", -- Create a tag on the revision under cursor summary = "", -- Show summary tooltip for revision under cursor summary_tooltip = { diff --git a/lua/jj/cmd/init.lua b/lua/jj/cmd/init.lua index 2ab1b85..510d46a 100644 --- a/lua/jj/cmd/init.lua +++ b/lua/jj/cmd/init.lua @@ -56,6 +56,7 @@ local split_module = require("jj.cmd.split") --- @field summary_tooltip? jj.cmd.summary_tooltip.keymaps --- @field tag_set? string|string[] --- @field history? string|string[] +--- @field change_revset? string|string[] --- @class jj.cmd.rebase.keymaps --- @field onto? string|string[] @@ -199,6 +200,7 @@ M.config = { split = "", tag_set = "", history = "", + change_revset = "", }, status = { open_file = "", diff --git a/lua/jj/cmd/log.lua b/lua/jj/cmd/log.lua index 6f31f53..b5dad19 100644 --- a/lua/jj/cmd/log.lua +++ b/lua/jj/cmd/log.lua @@ -692,6 +692,15 @@ function M.handle_log_tag_set(revset) require("jj.cmd").tag_set(revset) end +--- Handle log change revset +function M.handle_log_change_revset() + vim.ui.input({ prompt = "Enter new revset: " }, function(input) + if input and input ~= "" then + M.log({ revisions = input }) + end + end) +end + --- Handle opening a PR/MR from `jj log` buffer for the revision under cursor --- @param list_bookmarks? boolean If true, prompt to select from all bookmarks instead of using current revision function M.handle_log_open_pr(list_bookmarks) @@ -1153,6 +1162,11 @@ function M.log_keymaps() handler = M.handle_log_history, modes = { "v" }, }, + change_revset = { + desc = "Change the revset(s) being viewed", + handler = M.handle_log_change_revset, + modes = { "n", "v" }, + }, } local merged_keymaps = cmd.merge_keymaps(cmd.resolve_keymaps_from_specs(keymaps, specs), cmd.terminal_keymaps())