branch: externals/vc-jj
commit f2d7f4f93631fa190809b0d090b0780e6777aa10
Author: Kristoffer Balintona <[email protected]>
Commit: Kristoffer Balintona <[email protected]>
Use full change IDs for entries in Log View buffers
Previously, we would use a short change ID in JJ Log View buffers.
However, a risk arises from stale Log View buffers (Log View buffers
that are not updated to the current repository state): operations in
stale Log View buffers may mistakenly operate on current revisions
whose short change ID happen to match a change ID in the stale Log
View buffer.
Consequently, in these stale Log View buffers, users may accidentally
operate on revisions they don't intend to operate on.
To guarantee operations within the Log View buffer do not operate
mistakenly on the wrong revisions, we should use the full change IDs
of revisions in JJ Log View buffers.
Our solution is:
- Change `vc-jj--log-default-template' such that the full change ID
precedes change_id.shortest().prefix() and
change_id.shortest().rest, using a zero width space to separate the
components.
- Change `vc-jj--logline-re' to create a new regexp capture group for
the full change ID in `vc-jj--log-default-template'.
- Change the local value of `log-view-font-lock-keywords' in
`vc-jj-log-view-mode' buffers such that the full change ID is
matched against and has the 'invisible text property.
Effectively, the full change ID is present in the Log View buffer but
invisible, leaving the visible text unchanged.
Fixes #112.
---
NEWS.org | 1 +
vc-jj.el | 30 +++++++++++++++++-------------
2 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/NEWS.org b/NEWS.org
index 7553fb538a..3f1da8ea3e 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -20,6 +20,7 @@
- Fixed =vc-jj-diff= not transforming filenames into jj fileset syntax. This
means commands like =vc-diff= and =log-view-diff= do not fail.
- Fixed a bug related to vc-jj's integration with project.el in cases where a
.git repo is within a subdirectory of a .jj repo. Previously, when inside the
.git repo, project.el would erroneously detect the .jj repo to be current one
(instead of the .git repo, which is closer). Now, project.el correctly detects
the closer .git repo.
+ ~vc-jj-bookmark-delete~ properly recognize the names of local bookmarks that
are pushable to a remote.
+- Prevent the possibility of operating on the wrong revisions when in stale JJ
Log View buffers (Log View buffers that are not up-to-date with the repository).
** [[https://codeberg.org/emacs-jj-vc/vc-jj.el/compare/v0.3...v0.4][0.4]] -
2025-09-03
diff --git a/vc-jj.el b/vc-jj.el
index fac7cfc007..a95881638e 100644
--- a/vc-jj.el
+++ b/vc-jj.el
@@ -619,7 +619,7 @@ if(root,
label(if(current_working_copy, \"working_copy\"),
concat(
separate(\" \",
- change_id.shortest(8).prefix() ++ \"\" ++
change_id.shortest(8).rest(),
+ change_id ++ \"\" ++ change_id.shortest(8).prefix() ++ \"\" ++
change_id.shortest(8).rest(),
if(author.name(), author.name(), if(author.email(),
author.email().local(), email_placeholder)),
commit_timestamp(self).format(\"%Y-%m-%d\"),
bookmarks,
@@ -682,7 +682,10 @@ if(root,
;; graph
(+? nonl)
" "
- ;; change-id
+ ;; full change id
+ (group (+ (any "K-Zk-z")))
+ space
+ ;; displayed change id
(group (+ (any "K-Zk-z")))
space
(group (+ (any "K-Zk-z")))
@@ -842,18 +845,19 @@ delete."
;; Allow expanding short log entries.
(setq truncate-lines t)
(setq-local log-view-expanded-log-entry-function
- 'vc-jj--expanded-log-entry)
+ 'vc-jj--expanded-log-entry)
(setq-local log-view-font-lock-keywords
- `((,vc-jj--logline-re
- (1 'log-view-message)
- (2 'change-log-list)
- (3 'change-log-name)
- (4 'change-log-date)
- (5 'change-log-file)
- (6 'change-log-list)
- (7 'change-log-function)
- (8 'change-log-function))))
-
+ `((,vc-jj--logline-re
+ (1 '(face nil invisible t))
+ (2 'log-view-message)
+ (3 'change-log-list)
+ (4 'change-log-name)
+ (5 'change-log-date)
+ (6 'change-log-file)
+ (7 'change-log-list)
+ (8 'change-log-function)
+ (9 'change-log-function))))
+
(keymap-set vc-jj-log-view-mode-map "r" #'vc-jj-log-view-edit-change)
(keymap-set vc-jj-log-view-mode-map "x" #'vc-jj-log-view-abandon-change)
(keymap-set vc-jj-log-view-mode-map "i" #'vc-jj-log-view-new-change)