From 36a9a4842ee91595437cf0cf1eff30fe8b525f0a Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Mon, 28 Oct 2024 21:46:06 +0800 Subject: [PATCH] Fix C-c C-d and C-c C-w during log-view-modify-change-comment * lisp/vc/vc-dispatcher.el (log-edit-diff-fileset) (log-edit-diff-patch): Declare. (vc-log-edit, vc-start-logentry): New optional argument DIFF-FUNCTION to specify log-edit-diff-function in the generated Log Edit buffer. * lisp/vc/vc.el (vc-modify-change-comment): Pass the new DIFF-FUNCTION argument to vc-start-logentry. (cherry picked from commit fc3de939b9059dd4436134f08e7fa7149087c317) --- lisp/vc/vc-dispatcher.el | 15 ++++++++++----- lisp/vc/vc.el | 13 ++++++++++++- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el index 36456fdb2e2..9bd1d104440 100644 --- a/lisp/vc/vc-dispatcher.el +++ b/lisp/vc/vc-dispatcher.el @@ -685,10 +685,12 @@ NOT-URGENT means it is ok to continue if the user says not to save." ;; Set up key bindings for use while editing log messages (declare-function log-edit-empty-buffer-p "log-edit" ()) +(declare-function log-edit-diff-fileset "log-edit" ()) +(declare-function log-edit-diff-patch "log-edit" ()) (defvar vc-patch-string) -(defun vc-log-edit (fileset mode backend) +(defun vc-log-edit (fileset mode backend &optional diff-function) "Set up `log-edit' for use on FILE." (setq default-directory (buffer-local-value 'default-directory vc-parent-buffer)) @@ -718,7 +720,9 @@ NOT-URGENT means it is ok to continue if the user says not to save." (lambda (file) (file-relative-name file root)) fileset)))) (log-edit-diff-function - . ,(if vc-patch-string 'log-edit-diff-patch 'log-edit-diff-fileset)) + . ,(cond (diff-function) + (vc-patch-string #'log-edit-diff-patch) + (t #'log-edit-diff-fileset))) (log-edit-vc-backend . ,backend) (vc-log-fileset . ,fileset) (vc-patch-string . ,vc-patch-string)) @@ -727,7 +731,7 @@ NOT-URGENT means it is ok to continue if the user says not to save." (set-buffer-modified-p nil) (setq buffer-file-name nil)) -(defun vc-start-logentry (files comment initial-contents msg logbuf mode action &optional after-hook backend patch-string) +(defun vc-start-logentry (files comment initial-contents msg logbuf mode action &optional after-hook backend patch-string diff-function) "Accept a comment for an operation on FILES. If COMMENT is nil, pop up a LOGBUF buffer, emit MSG, and set the action on close to ACTION. If COMMENT is a string and @@ -740,7 +744,8 @@ empty comment. Remember the file's buffer in `vc-parent-buffer' MODE, defaulting to `log-edit-mode' if MODE is nil. AFTER-HOOK specifies the local value for `vc-log-after-operation-hook'. BACKEND, if non-nil, specifies a VC backend for the Log Edit buffer. -PATCH-STRING is a patch to check in." +PATCH-STRING is a patch to check in. +DIFF-FUNCTION is `log-edit-diff-function' for the Log Edit buffer." (let ((parent (if (and (length= files 1) (not (vc-dispatcher-browsing))) (get-file-buffer (car files)) @@ -755,7 +760,7 @@ PATCH-STRING is a patch to check in." (concat " from " (buffer-name vc-parent-buffer))) (when patch-string (setq-local vc-patch-string patch-string)) - (vc-log-edit files mode backend) + (vc-log-edit files mode backend diff-function) (make-local-variable 'vc-log-after-operation-hook) (when after-hook (setq vc-log-after-operation-hook after-hook)) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index e9b8dc5c043..a3dc7239eab 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -2528,7 +2528,18 @@ the variable `vc-BACKEND-header'." ;; So refresh the view. (when (derived-mode-p 'log-view-mode) (revert-buffer))) - nil backend))) + nil backend nil + (lambda () + ;; Here we want the root diff for REV, even if we were called + ;; from a buffer generated by C-x v l, because the change comment + ;; we will edit applies to the whole revision. + (let* ((rootdir + (vc-call-backend backend 'root default-directory)) + (prevrev + (vc-call-backend backend + 'previous-revision rootdir rev))) + (vc-diff-internal nil (list backend (list rootdir)) + prevrev rev)))))) ;;;###autoload (defun vc-merge () -- 2.39.5