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.
This commit is contained in:
Sean Whitton 2024-10-28 21:46:06 +08:00
parent b7b55dfc03
commit fc3de939b9
2 changed files with 22 additions and 6 deletions

View file

@ -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))

View file

@ -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 ()