unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* vc-modify-change-comment for "modern" backend fix
@ 2022-05-17  7:04 Alfred M. Szmidt
  2022-05-17  8:36 ` Alfred M. Szmidt
  0 siblings, 1 reply; 15+ messages in thread
From: Alfred M. Szmidt @ 2022-05-17  7:04 UTC (permalink / raw)
  To: emacs-devel

I'm trying to add vc-modify-change-comment functionality to vc-fossil,
but running into a small issue in log-view.el, namley the following
mentioned in vc.el:

;; - Second, `log-view-modify-change-comment' doesn't seem to support
;;   modern backends at all because `log-view-extract-comment'
;;   unconditionally calls `log-view-current-file'.  This should be easy to
;;   fix.

There are two ways to fix it, one is to just check if
log-view-per-file-logs is set before calling log-view-extract-comment,
or simply make sure that log-view-current-file behaves.

Attached two patches, the first modifies all calleers and
log-view-current-file, the second just log-view-extract-comment.  I
think the first one is preferable...

Thoughts?

diff --git a/lisp/vc/log-view.el b/lisp/vc/log-view.el
index 415b1564ed..791ef66c92 100644
--- a/lisp/vc/log-view.el
+++ b/lisp/vc/log-view.el
@@ -282,22 +282,24 @@ log-view-dir-re
 
 (defun log-view-current-file ()
   "Return the current file."
-  (save-excursion
-    (forward-line 1)
-    (or (re-search-backward log-view-file-re nil t)
-	(re-search-forward log-view-file-re nil t)
-	(error "Unable to determine the current file"))
-    (let* ((file (match-string 1))
-	   (cvsdir (and (re-search-backward log-view-dir-re nil t)
-			(match-string 1)))
-	   (pcldir (and (boundp 'cvs-pcl-cvs-dirchange-re)
-			(re-search-backward cvs-pcl-cvs-dirchange-re nil t)
-			(match-string 1)))
-	   (dir ""))
-      (let ((default-directory ""))
-	(when pcldir (setq dir (expand-file-name pcldir dir)))
-	(when cvsdir (setq dir (expand-file-name cvsdir dir))))
-      (expand-file-name file dir))))
+  (if log-view-per-file-logs
+      (save-excursion
+        (forward-line 1)
+        (or (re-search-backward log-view-file-re nil t)
+	    (re-search-forward log-view-file-re nil t)
+	    (error "Unable to determine the current file"))
+        (let* ((file (match-string 1))
+	       (cvsdir (and (re-search-backward log-view-dir-re nil t)
+			    (match-string 1)))
+	       (pcldir (and (boundp 'cvs-pcl-cvs-dirchange-re)
+			    (re-search-backward cvs-pcl-cvs-dirchange-re nil t)
+			    (match-string 1)))
+	       (dir ""))
+          (let ((default-directory ""))
+	    (when pcldir (setq dir (expand-file-name pcldir dir)))
+	    (when cvsdir (setq dir (expand-file-name cvsdir dir))))
+          (expand-file-name file dir)))
+    (car log-view-vc-fileset)))
 
 (defun log-view-current-entry (&optional pos move)
   "Return the position and revision tag of the Log View entry at POS.
@@ -512,9 +514,7 @@ log-view-find-revision
       (user-error "Multiple files shown in this buffer, cannot use this command here")))
   (save-excursion
     (goto-char pos)
-    (switch-to-buffer (vc-find-revision (if log-view-per-file-logs
-					    (log-view-current-file)
-					  (car log-view-vc-fileset))
+    (switch-to-buffer (vc-find-revision (log-view-current-file)
 					(log-view-current-tag)))))
 
 
@@ -541,9 +541,7 @@ log-view-extract-comment
 (defun log-view-modify-change-comment ()
   "Edit the change comment displayed at point."
   (interactive)
-  (vc-modify-change-comment (list (if log-view-per-file-logs
-				      (log-view-current-file)
-				    (car log-view-vc-fileset)))
+  (vc-modify-change-comment (list (log-view-current-file))
 			    (log-view-current-tag)
 			    (log-view-extract-comment)))
 
@@ -558,9 +556,7 @@ log-view-annotate-version
       (user-error "Multiple files shown in this buffer, cannot use this command here")))
   (save-excursion
     (goto-char pos)
-    (vc-annotate (if log-view-per-file-logs
-		     (log-view-current-file)
-		   (car log-view-vc-fileset))
+    (vc-annotate (log-view-current-file)
 		 (log-view-current-tag))))
 
 ;;
@@ -620,9 +616,7 @@ log-view-diff-common
              ;; diff for all the files in the changeset, pass NIL for
              ;; the file list.
              (unless whole-changeset
-               (if log-view-per-file-logs
-                   (list (log-view-current-file))
-                 log-view-vc-fileset)))
+                   (list (log-view-current-file))))
      fr to)))
 
 (provide 'log-view)

diff --git a/lisp/vc/log-view.el b/lisp/vc/log-view.el
index 415b1564ed..83557402fc 100644
--- a/lisp/vc/log-view.el
+++ b/lisp/vc/log-view.el
@@ -521,7 +521,10 @@ log-view-find-revision
 (defun log-view-extract-comment ()
   "Parse comment from around the current point in the log."
   (save-excursion
-    (let (st en (backend (vc-backend (log-view-current-file))))
+    (let (st en (backend (vc-backend
+                          (if log-view-per-file-logs
+                              (log-view-current-file)
+                            (car log-view-vc-fileset)))))
       (log-view-end-of-defun)
       (cond ((eq backend 'SVN)
 	     (forward-line -1)))



^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2022-05-19 14:47 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-17  7:04 vc-modify-change-comment for "modern" backend fix Alfred M. Szmidt
2022-05-17  8:36 ` Alfred M. Szmidt
2022-05-17 12:02   ` Eli Zaretskii
2022-05-17 18:31   ` Stefan Monnier
2022-05-17 19:10     ` Alfred M. Szmidt
2022-05-17 23:20       ` Dmitry Gutov
2022-05-18  6:34     ` Alfred M. Szmidt
2022-05-18 11:29       ` Eli Zaretskii
2022-05-19  6:11         ` Alfred M. Szmidt
2022-05-19 14:47           ` Stefan Monnier
2022-05-19  0:05       ` Dmitry Gutov
2022-05-19  6:11         ` Alfred M. Szmidt
2022-05-19  9:25           ` Dmitry Gutov
2022-05-19  9:58             ` Alfred M. Szmidt
2022-05-19 10:24               ` Dmitry Gutov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).