branch: externals/vc-jj commit 5eae1d07b5e55fa50e60afaddf85a77c9c3654f7 Merge: 6621c9b6ab 1b26a80078 Author: Wojciech Siewierski <vi...@noreply.codeberg.org> Commit: Wojciech Siewierski <vi...@noreply.codeberg.org>
Merge pull request 'Make the log customizable' (#9) from rudi/vc-jj.el:push-ooxqzmotyxxz into master Reviewed-on: https://codeberg.org/vifon/vc-jj.el/pulls/9 --- vc-jj.el | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/vc-jj.el b/vc-jj.el index fb57583bb3..6a2111473e 100644 --- a/vc-jj.el +++ b/vc-jj.el @@ -26,6 +26,7 @@ (require 'seq) (autoload 'vc-switches "vc") +(autoload 'ansi-color-apply-on-region "ansi-color") (add-to-list 'vc-handled-backends 'JJ) @@ -33,6 +34,22 @@ (defun vc-jj-checkout-model (_files) 'implicit) (defun vc-jj-update-on-retrieve-tag () nil) +(defgroup vc-jj nil + "VC Jujutsu backend." + :group 'vc) + +(defcustom vc-jj-colorize-log t + "Control whether to have jj colorize the log." + :type 'boolean) + +(defcustom vc-jj-log-template "builtin_log_compact" + "The template to use for `vc-print-log'." + :type '(radio (const "builtin_log_oneline") + (const "builtin_log_compact") + (const "builtin_log_comfortable") + (const "builtin_log_compact_full_description") + (const "builtin_log_detailed") + (string :tag "Custom template"))) (defun vc-jj--file-tracked (file) (with-temp-buffer @@ -230,16 +247,23 @@ self.hidden(), \"\\n\" (call-process "jj" nil nil nil "restore" "--" file)) (defun vc-jj-print-log (files buffer &optional _shortlog start-revision limit) + "Print commit log associated with FILES into specified BUFFER." + ;; FIXME: limit can be a revision string, in which case we should + ;; print revisions between start-revision and limit (let ((inhibit-read-only t) - (erase-buffer) (args (append (when limit (list "-n" (number-to-string limit))) (when start-revision (list "-r" (concat ".." start-revision))) - (list "--") + (when vc-jj-colorize-log (list "--color" "always")) + (list "-T" vc-jj-log-template "--") files))) - (apply #'call-process "jj" nil buffer nil "log" args)) + (with-current-buffer buffer (erase-buffer)) + (apply #'call-process "jj" nil buffer nil "log" args) + (when vc-jj-colorize-log + (with-current-buffer buffer + (ansi-color-apply-on-region (point-min) (point-max))))) (goto-char (point-min))) (defun vc-jj-show-log-entry (revision)