changeset 87432:315124ffb889

* (vc.el, vc-sccs.el, vc-rcs.el, vc-cs.el, vc-mcvs.el): Put machinery in place to support editing of change comments with 'e' in a log-view buffer. Not documented yet as this only works for SCCS, RCS, and maybe CVS if you have admin privileges. When we have backend support for Subversion and more modern systems it will ve time to write this up.
author Eric S. Raymond <esr@snark.thyrsus.com>
date Thu, 27 Dec 2007 11:26:27 +0000
parents 59242fb42f3a
children 410e13519acb
files lisp/ChangeLog lisp/log-view.el lisp/vc-cvs.el lisp/vc-mcvs.el lisp/vc-rcs.el lisp/vc-sccs.el lisp/vc.el
diffstat 7 files changed, 74 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Thu Dec 27 10:28:28 2007 +0000
+++ b/lisp/ChangeLog	Thu Dec 27 11:26:27 2007 +0000
@@ -1,3 +1,12 @@
+2007-12-27  Eric S. Raymond  <esr@snark.thyrsus.com>
+
+	* (vc.el, vc-sccs.el, vc-rcs.el, vc-cs.el, vc-mcvs.el): Put
+	machinery in place to support editing of change comments
+	with 'e' in a log-view buffer.  Not documented yet as this
+	only works for SCCS, RCS, and maybe CVS if you have admin
+	privileges.  When we have backend support for Subversion and
+	more modern systems it will ve time to write this up.
+
 2007-12-27  Kenichi Handa  <handa@ni.aist.go.jp>
 
 	* international/mule-cmds.el (select-safe-coding-system): When a
--- a/lisp/log-view.el	Thu Dec 27 10:28:28 2007 +0000
+++ b/lisp/log-view.el	Thu Dec 27 11:26:27 2007 +0000
@@ -128,7 +128,7 @@
   '(("q" . quit-window)
     ("z" . kill-this-buffer)
     ("m" . log-view-toggle-mark-entry)
-    ;; ("e" . cvs-mode-edit-log)
+    ("e" . log-view-modify-change-comment)
     ("d" . log-view-diff)
     ("a" . log-view-annotate-version)
     ("f" . log-view-find-revision)
@@ -411,6 +411,31 @@
     (switch-to-buffer (vc-find-revision (log-view-current-file)
                                        (log-view-current-tag)))))
 
+
+(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))))
+      (log-view-end-of-defun)
+      (cond ((eq backend 'SVN)
+	     (forward-line -1)))
+      (setq en (point))
+      (log-view-beginning-of-defun)
+      (cond ((memq backend '(SCCS RCS CVS MCVS SVN))
+	     (forward-line 2))
+	    ((eq backend 'Hg)
+	     (forward-line 4)
+	     (re-search-forward "summary: *" nil t)))      
+      (setq st (point))
+      (buffer-substring st en))))
+
+(defun log-view-modify-change-comment ()
+  "Edit the change comment displayed at point."
+  (interactive)
+  (vc-modify-change-comment (list (log-view-current-file))
+			  (log-view-current-tag)
+			  (log-view-extract-comment)))
+
 (defun log-view-annotate-version (pos)
   "Annotate the version at point."
   (interactive "d")
--- a/lisp/vc-cvs.el	Thu Dec 27 10:28:28 2007 +0000
+++ b/lisp/vc-cvs.el	Thu Dec 27 11:26:27 2007 +0000
@@ -494,6 +494,10 @@
             (error "Couldn't analyze cvs update result")))
       (message "Merging changes into %s...done" file))))
 
+(defun vc-cvs-modify-change-comment (files rev comment)
+  "Modify the change comments for FILES on a specified REV. 
+Will fail unless you have administrative privileges on the repo."
+  (vc-cvs-command nil 0 files "rcs" (concat "-m" comment ":" rev)))
 
 ;;;
 ;;; History functions
--- a/lisp/vc-mcvs.el	Thu Dec 27 10:28:28 2007 +0000
+++ b/lisp/vc-mcvs.el	Thu Dec 27 11:26:27 2007 +0000
@@ -432,6 +432,12 @@
             (error "Couldn't analyze mcvs update result")))
       (message "Merging changes into %s...done" file))))
 
+(defun vc-mcvs-modify-change-comment (files rev comment)
+  "Modify the change comments for FILES on a specified REV. 
+Will fail unless you have administrative privileges on the repo."
+  (vc-mcvs-command nil 0 files "rcs" (concat "-m" comment ":" rev)))
+
+
 ;;;
 ;;; History functions
 ;;;
--- a/lisp/vc-rcs.el	Thu Dec 27 10:28:28 2007 +0000
+++ b/lisp/vc-rcs.el	Thu Dec 27 11:26:27 2007 +0000
@@ -510,6 +510,11 @@
   ;; expanded headers.
   (vc-do-command nil 0 "co" (vc-name file) "-f" (concat "-l" rev)))
 
+(defun vc-rcs-modify-change-comment (files rev comment)
+  "Modify the change comments change on FILES on a specified REV."
+  (dolist (file files)
+    (vc-do-command nil 0 "rcs" (vc-name file) 
+		   (concat "-m" comment ":" rev))))
 
 
 ;;;
--- a/lisp/vc-sccs.el	Thu Dec 27 10:28:28 2007 +0000
+++ b/lisp/vc-sccs.el	Thu Dec 27 11:26:27 2007 +0000
@@ -285,6 +285,12 @@
   (vc-do-command nil 0 "unget" (vc-name file) "-n" (if rev (concat "-r" rev)))
   (vc-do-command nil 0 "get" (vc-name file) "-g" (if rev (concat "-r" rev))))
 
+(defun vc-sccs-modify-change-comment (files rev comment)
+  "Modify (actually, append to) the change comments for FILES on a specified REV."
+  (dolist (file files)
+    (vc-do-command nil 0 "cdc" (vc-name file) 
+		   (concat "-y" comment) (concat "-r" rev))))
+
 
 ;;;
 ;;; History functions
--- a/lisp/vc.el	Thu Dec 27 10:28:28 2007 +0000
+++ b/lisp/vc.el	Thu Dec 27 11:26:27 2007 +0000
@@ -318,6 +318,11 @@
 ;;   used for files under this backend, and if files can indeed be
 ;;   locked by other users.
 ;;
+;; - modify-change-comment (files rev comment)
+;;
+;;   Modify the change comments associated with the files at the 
+;;   given revision.  This is optional, many backends do not support it.
+;;
 ;; HISTORY FUNCTIONS
 ;;
 ;; * print-log (files &optional buffer)
@@ -2137,6 +2142,19 @@
 	  (vc-call-backend backend 'clear-headers)
 	  (kill-buffer filename)))))
 
+(defun vc-modify-change-comment (files rev oldcomment)
+  "Edit the comment associated with the given files and revision."
+  (vc-start-entry
+   files rev oldcomment t
+   "Enter a replacement change comment."
+   (lambda (files rev comment)
+     (vc-call-backend 
+      ;; Less of a kluge than it looks like; log-view mode only passes
+      ;; this function a singleton list.  Arguments left in this form in
+      ;; case the more general operation ever becomes meaningful. 
+      (vc-responsible-backend (car files)) 
+      'modify-change-comment files rev comment))))
+
 ;;;###autoload
 (defun vc-merge ()
   "Merge changes between two revisions into the current buffer's file.