diff lisp/vc-annotate.el @ 106472:6e0f1038bc44

Support showing a single log entry from vc-annotate. * vc.el (print-log): Add a new argument: START-REVISION. (vc-print-log-internal): Add a new optional argument and pass it to the backend. (vc-print-log, vc-print-root-log): Adjust callers. * vc-annotate.el (vc-annotate-show-log-revision-at-line): If a buffer already displays the requested log entry, use it. Otherwise display only the log entry in question. * vc-svn.el (vc-svn-print-log): * vc-mtn.el (log-view-file-re): * vc-hg.el (vc-hg-state): * vc-git.el (vc-git-print-log): Add support for new argument START-REVISION. (vc-git-show-log-entry): Return t on success. * vc-bzr.el (vc-bzr-print-log): Add support new argument START-REVISION. (vc-bzr-show-log-entry): Return t on success. * vc-rcs.el (vc-rcs-print-log): * vc-sccs.el (vc-sccs-print-log): * vc-cvs.el (vc-cvs-print-log): Add new argument, ignore it.
author Dan Nicolaescu <dann@ics.uci.edu>
date Mon, 07 Dec 2009 09:02:11 +0000
parents 456620b3e939
children badae536951d
line wrap: on
line diff
--- a/lisp/vc-annotate.el	Mon Dec 07 06:56:40 2009 +0000
+++ b/lisp/vc-annotate.el	Mon Dec 07 09:02:11 2009 +0000
@@ -479,15 +479,37 @@
 	(vc-annotate-warp-revision prev-rev fname)))))
 
 (defun vc-annotate-show-log-revision-at-line ()
-  "Visit the log of the revision at line."
+  "Visit the log of the revision at line.
+If the VC backend supports it, only show the log entry for the revision.
+If a *vc-change-log* buffer exists and already shows a log for
+the file in question, search for the log entry required and move point ."
   (interactive)
   (if (not (equal major-mode 'vc-annotate-mode))
       (message "Cannot be invoked outside of a vc annotate buffer")
     (let ((rev-at-line (vc-annotate-extract-revision-at-line)))
       (if (not rev-at-line)
 	  (message "Cannot extract revision number from the current line")
-	(vc-print-log-internal
-	 vc-annotate-backend (list (cdr rev-at-line)) (car rev-at-line) nil)))))
+	(let ((backend vc-annotate-backend)
+	      (log-buf (get-buffer "*vc-change-log*"))
+	      pos)
+	  (if (and
+	       log-buf
+	       ;; Look for a log buffer that already displays the correct file.
+	       (with-current-buffer log-buf
+		 (and (eq backend log-view-vc-backend)
+		      (null (cdr log-view-vc-fileset))
+		      (string= (car log-view-vc-fileset) (cdr rev-at-line))
+		      ;; Check if the entry we require can be found.
+		      (vc-call-backend
+		       backend 'show-log-entry (car rev-at-line))
+		      (setq pos (point)))))
+	      (progn
+		(pop-to-buffer log-buf)
+		(goto-char pos))
+	    ;; Ask the backend to display a single log entry.
+	    (vc-print-log-internal
+	     vc-annotate-backend (list (cdr rev-at-line))
+	     (car rev-at-line) t 1)))))))
 
 (defun vc-annotate-show-diff-revision-at-line-internal (filediff)
   (if (not (equal major-mode 'vc-annotate-mode))