aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Whitton2024-10-17 21:04:38 +0800
committerSean Whitton2024-10-17 21:24:10 +0800
commit01c8f31a54df511913ad88cb6138a01390faafbe (patch)
tree2d3708f9e3f5dee59f506d27d8141c645bffd1fb
parent475a33adb9134990fa05be8a6308216f12ed4ef7 (diff)
downloademacs-01c8f31a54df511913ad88cb6138a01390faafbe.tar.gz
emacs-01c8f31a54df511913ad88cb6138a01390faafbe.zip
New get-change-comment VC backend action
This gets us closer to using log-view-modify-change-comment with modern VCS. What remains is implementing the modify-change-comment backend action for those VCS. * lisp/vc/vc.el: New get-change-comment backend action. (vc-modify-change-comment): Pass the backend to vc-start-logentry. * lisp/vc/log-view.el (log-view-extract-comment): Use new get-change-comment action. * lisp/vc/vc-git.el (vc-git-get-change-comment): Factor out of vc-git-log-edit-toggle-amend.
-rw-r--r--lisp/vc/log-view.el16
-rw-r--r--lisp/vc/vc-git.el14
-rw-r--r--lisp/vc/vc.el16
3 files changed, 28 insertions, 18 deletions
diff --git a/lisp/vc/log-view.el b/lisp/vc/log-view.el
index e9e6602e414..0533af62343 100644
--- a/lisp/vc/log-view.el
+++ b/lisp/vc/log-view.el
@@ -543,11 +543,17 @@ If called interactively, visit the version at point."
543(defun log-view-modify-change-comment () 543(defun log-view-modify-change-comment ()
544 "Edit the change comment displayed at point." 544 "Edit the change comment displayed at point."
545 (interactive) 545 (interactive)
546 (vc-modify-change-comment (list (if log-view-per-file-logs 546 (let* ((files (list (if log-view-per-file-logs
547 (log-view-current-file) 547 (log-view-current-file)
548 (car log-view-vc-fileset))) 548 (car log-view-vc-fileset))))
549 (log-view-current-tag) 549 (rev (log-view-current-tag))
550 (log-view-extract-comment))) 550 ;; `log-view-extract-comment' is the legacy code for this; the
551 ;; `get-change-comment' backend action is the new way to do it.
552 (comment (condition-case _
553 (vc-call-backend log-view-vc-backend
554 'get-change-comment files rev)
555 (vc-not-supported (log-view-extract-comment)))))
556 (vc-modify-change-comment files rev comment)))
551 557
552(defun log-view-annotate-version (pos) 558(defun log-view-annotate-version (pos)
553 "Annotate the version at POS. 559 "Annotate the version at POS.
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 5a7ffeffc9d..f77bf0cc5ff 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -67,6 +67,7 @@
67;; - merge-news (file) see `merge-file' 67;; - merge-news (file) see `merge-file'
68;; - mark-resolved (files) OK 68;; - mark-resolved (files) OK
69;; - steal-lock (file &optional revision) NOT NEEDED 69;; - steal-lock (file &optional revision) NOT NEEDED
70;; - get-change-comment (files rev) OK
70;; HISTORY FUNCTIONS 71;; HISTORY FUNCTIONS
71;; * print-log (files buffer &optional shortlog start-revision limit) OK 72;; * print-log (files buffer &optional shortlog start-revision limit) OK
72;; * log-outgoing (buffer remote-location) OK 73;; * log-outgoing (buffer remote-location) OK
@@ -1037,12 +1038,8 @@ See `vc-git-log-edit-summary-max-len'.")
1037 "Toggle whether this will amend the previous commit. 1038 "Toggle whether this will amend the previous commit.
1038If toggling on, also insert its message into the buffer." 1039If toggling on, also insert its message into the buffer."
1039 (interactive) 1040 (interactive)
1040 (log-edit--toggle-amend 1041 (log-edit--toggle-amend (lambda ()
1041 (lambda () 1042 (vc-git-get-change-comment nil "HEAD"))))
1042 (with-output-to-string
1043 (vc-git-command
1044 standard-output 1 nil
1045 "log" "--max-count=1" "--pretty=format:%B" "HEAD")))))
1046 1043
1047(defvar-keymap vc-git-log-edit-mode-map 1044(defvar-keymap vc-git-log-edit-mode-map
1048 :name "Git-Log-Edit" 1045 :name "Git-Log-Edit"
@@ -1958,6 +1955,11 @@ This requires git 1.8.4 or later, for the \"-L\" option of \"git log\"."
1958(defun vc-git-mark-resolved (files) 1955(defun vc-git-mark-resolved (files)
1959 (vc-git-command nil 0 files "add")) 1956 (vc-git-command nil 0 files "add"))
1960 1957
1958(defun vc-git-get-change-comment (_files rev)
1959 (with-output-to-string
1960 (vc-git-command standard-output 1 nil
1961 "log" "--max-count=1" "--pretty=format:%B" rev)))
1962
1961(defvar vc-git-extra-menu-map 1963(defvar vc-git-extra-menu-map
1962 (let ((map (make-sparse-keymap))) 1964 (let ((map (make-sparse-keymap)))
1963 (define-key map [git-grep] 1965 (define-key map [git-grep]
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index a30ba06aec3..5d7ebc05d4c 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -309,6 +309,12 @@
309;; used for files under this backend, and if files can indeed be 309;; used for files under this backend, and if files can indeed be
310;; locked by other users. 310;; locked by other users.
311;; 311;;
312;; - get-change-comment (files rev)
313;;
314;; Return the change comments associated with the files at the given
315;; revision. The FILES argument it for forward-compatibility;
316;; existing implementations care only about REV.
317;;
312;; - modify-change-comment (files rev comment) 318;; - modify-change-comment (files rev comment)
313;; 319;;
314;; Modify the change comments associated with the files at the 320;; Modify the change comments associated with the files at the
@@ -706,12 +712,7 @@
706;; - The git backend supports amending, but in a different 712;; - The git backend supports amending, but in a different
707;; way (press `C-c C-e' in log-edit buffer, when making a new commit). 713;; way (press `C-c C-e' in log-edit buffer, when making a new commit).
708;; 714;;
709;; - Second, `log-view-modify-change-comment' doesn't seem to support 715;; - Doing message editing in log-view might be a natural way to go
710;; modern backends at all because `log-view-extract-comment'
711;; unconditionally calls `log-view-current-file'. This should be easy to
712;; fix.
713;;
714;; - Third, doing message editing in log-view might be a natural way to go
715;; about it, but editing any but the last commit (and even it, if it's 716;; about it, but editing any but the last commit (and even it, if it's
716;; been pushed) is a dangerous operation in Git, which we shouldn't make 717;; been pushed) is a dangerous operation in Git, which we shouldn't make
717;; too easy for users to perform. 718;; too easy for users to perform.
@@ -2440,7 +2441,8 @@ the variable `vc-BACKEND-header'."
2440 (lambda () (vc-call-backend backend 'log-edit-mode)) 2441 (lambda () (vc-call-backend backend 'log-edit-mode))
2441 (lambda (files comment) 2442 (lambda (files comment)
2442 (vc-call-backend backend 2443 (vc-call-backend backend
2443 'modify-change-comment files rev comment))))) 2444 'modify-change-comment files rev comment))
2445 nil backend)))
2444 2446
2445;;;###autoload 2447;;;###autoload
2446(defun vc-merge () 2448(defun vc-merge ()