]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix C-c C-d and C-c C-w during log-view-modify-change-comment
authorSean Whitton <spwhitton@spwhitton.name>
Mon, 28 Oct 2024 13:46:06 +0000 (21:46 +0800)
committerEshel Yaron <me@eshelyaron.com>
Tue, 29 Oct 2024 09:57:26 +0000 (10:57 +0100)
* 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
lisp/vc/vc.el

index 36456fdb2e2d69bbfc4bf560963999df4f2ef41d..9bd1d104440cf6c4c77d95969a63b38932d7a8ef 100644 (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))
index e9b8dc5c0437d099545a3da2c781402016ff291c..a3dc7239eabda594fa5a9ea33cce81dfd2214d8b 100644 (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 ()