From 9b64a7f0cf4d2fb716182d26046f645ec58210b3 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 27 Dec 2007 11:26:27 +0000 Subject: [PATCH] * (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. --- lisp/ChangeLog | 9 +++++++++ lisp/log-view.el | 27 ++++++++++++++++++++++++++- lisp/vc-cvs.el | 4 ++++ lisp/vc-mcvs.el | 6 ++++++ lisp/vc-rcs.el | 5 +++++ lisp/vc-sccs.el | 6 ++++++ lisp/vc.el | 18 ++++++++++++++++++ 7 files changed, 74 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0de84114ed5..f9ae2f49158 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,12 @@ +2007-12-27 Eric S. Raymond + + * (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 * international/mule-cmds.el (select-safe-coding-system): When a diff --git a/lisp/log-view.el b/lisp/log-view.el index ceda42eb687..d14b33262cc 100644 --- a/lisp/log-view.el +++ b/lisp/log-view.el @@ -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 @@ log entries." (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") diff --git a/lisp/vc-cvs.el b/lisp/vc-cvs.el index 337170ab896..cdb3aae8020 100644 --- a/lisp/vc-cvs.el +++ b/lisp/vc-cvs.el @@ -494,6 +494,10 @@ The changes are between FIRST-REVISION and SECOND-REVISION." (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 diff --git a/lisp/vc-mcvs.el b/lisp/vc-mcvs.el index 70d502c7670..ba0ccf47747 100644 --- a/lisp/vc-mcvs.el +++ b/lisp/vc-mcvs.el @@ -432,6 +432,12 @@ The changes are between FIRST-REVISION and SECOND-REVISION." (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 ;;; diff --git a/lisp/vc-rcs.el b/lisp/vc-rcs.el index 35eba607bea..a092a91e918 100644 --- a/lisp/vc-rcs.el +++ b/lisp/vc-rcs.el @@ -510,6 +510,11 @@ Needs RCS 5.6.2 or later for -M." ;; 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)))) ;;; diff --git a/lisp/vc-sccs.el b/lisp/vc-sccs.el index 06fcff3ceb5..749ec83a196 100644 --- a/lisp/vc-sccs.el +++ b/lisp/vc-sccs.el @@ -285,6 +285,12 @@ locked. REV is the revision to check out." (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 diff --git a/lisp/vc.el b/lisp/vc.el index d8c99b25108..3d1132aab77 100644 --- a/lisp/vc.el +++ b/lisp/vc.el @@ -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 @@ The headers are reset to their non-expanded form." (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. -- 2.39.2