emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

vc-modify-change-comment for "modern" backend fix


From: Alfred M. Szmidt
Subject: vc-modify-change-comment for "modern" backend fix
Date: Tue, 17 May 2022 03:04:53 -0400

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]