unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Dan Nicolaescu <dann@ics.uci.edu>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: limit the number of log entries displayed by C-x v l
Date: Sun, 6 Dec 2009 09:43:32 -0800 (PST)	[thread overview]
Message-ID: <200912061743.nB6HhWU0029917@godzilla.ics.uci.edu> (raw)
In-Reply-To: <jwveinvgwxm.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Wed, 18 Nov 2009 19:52:22 -0500")

Stefan Monnier <monnier@iro.umontreal.ca> writes:

  > >> Having tried it on Bzr I see that it's still sufficiently slow with that
  > >> backend, that I might prefer to see the complete log so I can then
  > >> navigate it to see the various revisions I'm interested in, rather than
  > >> get a single-comment N times.
  > > Then one can just do C-x v l ...
  > 
  > Good point.
  > 
  > > The reason I found your idea to show a single entry interesting: with
  > > the limiting of C-x v l output that we do now by default, you can ask
  > > for a log in vc-annotate and not get it if the log entry is old enough.
  > > It's rather nice to see exactly the entry you asked for.
  > > So what should we do?
  > 
  > Change vc-annotate's code so that if the file's log is already displayed
  > in the *vc-change-log* buffer, it just jumps to the appropriate entry,
  > otherwise it does what your code did (i.e. ask the backend for just
  > that revision's log).

This patch does that.
OK?

Index: vc.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/vc.el,v
retrieving revision 1.744
diff -u -3 -p -r1.744 vc.el
--- vc.el	3 Dec 2009 03:11:17 -0000	1.744
+++ vc.el	6 Dec 2009 17:36:53 -0000
@@ -333,13 +333,16 @@
 ;;
 ;; HISTORY FUNCTIONS
 ;;
-;; * print-log (files buffer &optional shortlog limit)
+;; * print-log (files buffer &optional shortlog limit start-revision)
 ;;
 ;;   Insert the revision log for FILES into BUFFER.
 ;;   If SHORTLOG is true insert a short version of the log.
 ;;   If LIMIT is true insert only insert LIMIT log entries.  If the
 ;;   backend does not support limiting the number of entries to show
 ;;   it should return `limit-unsupported'.
+;;   If START-REVISION is given, then show the log starting from the
+;;   revision.  At this point START-REVISION is only required to work
+;;   in conjunction with LIMIT = 1.
 ;;
 ;; - log-view-mode ()
 ;;
@@ -1863,7 +1866,7 @@ Not all VC backends support short logs!"
 (defvar log-view-vc-fileset)
 
 (defun vc-print-log-internal (backend files working-revision
-                                      &optional limit)
+                                      &optional limit is-start-revision)
   ;; Don't switch to the output buffer before running the command,
   ;; so that any buffer-local settings in the vc-controlled
   ;; buffer can be accessed by the command.
@@ -1879,7 +1882,8 @@ Not all VC backends support short logs!"
 		       (memq 'file vc-log-short-style)))))
 
     (setq pl-return (vc-call-backend backend 'print-log files "*vc-change-log*"
-				     vc-short-log limit))
+				     vc-short-log limit
+				     (when is-start-revision working-revision)))
     (pop-to-buffer "*vc-change-log*")
     (let ((inhibit-read-only t))
       ;; log-view-mode used to be called with inhibit-read-only bound
@@ -1890,19 +1894,20 @@ Not all VC backends support short logs!"
 
     (vc-exec-after
      `(let ((inhibit-read-only t))
-	(when (and ,limit (not (eq 'limit-unsupported pl-return)))
+	(when (and ,limit (not ,(eq 'limit-unsupported pl-return))
+		   (not ,is-start-revision))
 	  (goto-char (point-max))
 	  (widget-create 'push-button
 			 :notify (lambda (&rest ignore)
 				   (vc-print-log-internal
-				    ',backend ',files ',working-revision (* 2 ,limit)))
+				    ',backend ',files ',working-revision (* 2 ,limit) nil))
 			 :help-echo "Show the log again, and double the number of log entries shown"
 			 "Show 2X entries")
 	  (widget-insert "    ")
 	  (widget-create 'push-button
 			 :notify (lambda (&rest ignore)
 				   (vc-print-log-internal
-				    ',backend ',files ',working-revision nil))
+				    ',backend ',files ',working-revision nil nil))
 			 :help-echo "Show the log again, showing all entries"
 			 "Show unlimited entries")
 	  (widget-setup))
@@ -1962,7 +1967,7 @@ If WORKING-REVISION is non-nil, leave th
       (error "Buffer is not version controlled"))
     (setq rootdir (vc-call-backend backend 'root default-directory))
     (setq working-revision (vc-working-revision rootdir))
-    (vc-print-log-internal backend (list rootdir) working-revision limit)))
+    (vc-print-log-internal backend (list rootdir) working-revision limit nil)))
 
 ;;;###autoload
 (defun vc-revert ()
Index: vc-annotate.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/vc-annotate.el,v
retrieving revision 1.12
diff -u -3 -p -r1.12 vc-annotate.el
--- vc-annotate.el	25 Nov 2009 23:47:35 -0000	1.12
+++ vc-annotate.el	6 Dec 2009 17:36:53 -0000
@@ -486,8 +486,24 @@ Return a cons (REV . FILENAME)."
     (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
+	       (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))
+		      (vc-call-backend
+		       backend 'show-log-entry (car rev-at-line))
+		      (setq pos (point)))))
+	      (progn
+		(pop-to-buffer log-buf)
+		(goto-char pos))
+	    (vc-print-log-internal
+	     vc-annotate-backend (list (cdr rev-at-line))
+	     (car rev-at-line) 1 t)))))))
 
 (defun vc-annotate-show-diff-revision-at-line-internal (filediff)
   (if (not (equal major-mode 'vc-annotate-mode))
Index: vc-bzr.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/vc-bzr.el,v
retrieving revision 1.89
diff -u -3 -p -r1.89 vc-bzr.el
--- vc-bzr.el	3 Dec 2009 08:53:06 -0000	1.89
+++ vc-bzr.el	6 Dec 2009 17:36:53 -0000
@@ -468,11 +468,11 @@ REV non-nil gets an error."
        ;; log-view-font-lock-keywords is careful to use the buffer-local
        ;; value of log-view-message-re only since Emacs-23.
        (if vc-short-log
-	 (append `((,log-view-message-re
-		    (1 'log-view-message-face)
-		    (2 'change-log-name)
-		    (3 'change-log-date)
-		    (4 'change-log-list))))
+	   '(("^ +\\([0-9]+\\) \\(.*?\\)[ \t]+\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}\\)\\( \\[merge\\]\\)?"
+              (1 'log-view-message-face)
+              (2 'change-log-name)
+              (3 'change-log-date)
+              (4 'change-log-list nil lax)))
 	 (append `((,log-view-message-re . 'log-view-message-face))
 		 ;; log-view-font-lock-keywords
 		 '(("^ *committer: \
@@ -481,7 +481,7 @@ REV non-nil gets an error."
 		    (2 'change-log-email))
 		   ("^ *timestamp: \\(.*\\)" (1 'change-log-date-face)))))))
 
-(defun vc-bzr-print-log (files buffer &optional shortlog limit)
+(defun vc-bzr-print-log (files buffer &optional shortlog limit start-revision)
   "Get bzr change log for FILES into specified BUFFER."
   ;; `vc-do-command' creates the buffer, but we need it before running
   ;; the command.
@@ -495,6 +495,7 @@ REV non-nil gets an error."
     (apply 'vc-bzr-command "log" buffer 'async files
 	   (append
 	    (when shortlog '("--short"))
+	    (when start-revision (list (format "-r..%s" start-revision)))
 	    (when limit (list "-l" (format "%s" limit)))
 	    (if (stringp vc-bzr-log-switches)
 		(list vc-bzr-log-switches)
@@ -504,7 +505,8 @@ REV non-nil gets an error."
   "Find entry for patch name REVISION in bzr change log buffer."
   (goto-char (point-min))
   (when revision
-    (let (case-fold-search)
+    (let (case-fold-search
+	  found)
       (if (re-search-forward
 	   ;; "revno:" can appear either at the beginning of a line,
 	   ;; or indented.
@@ -512,8 +514,11 @@ REV non-nil gets an error."
 		   ;; The revision can contain ".", quote it so that it
 		   ;; does not interfere with regexp matching.
 		   (regexp-quote revision) "$") nil t)
-	  (beginning-of-line 0)
-	(goto-char (point-min))))))
+	  (progn
+	    (beginning-of-line 0)
+	    (setq found t))
+	(goto-char (point-min)))
+      found)))
 
 (defun vc-bzr-diff (files &optional rev1 rev2 buffer)
   "VC bzr backend for diff."
Index: vc-hg.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/vc-hg.el,v
retrieving revision 1.107
diff -u -3 -p -r1.107 vc-hg.el
--- vc-hg.el	18 Nov 2009 19:12:26 -0000	1.107
+++ vc-hg.el	6 Dec 2009 17:36:53 -0000
@@ -219,7 +223,7 @@ If nil, use the value of `vc-diff-switch
                  (repeat :tag "Argument List" :value ("") string))
   :group 'vc-hg)
 
-(defun vc-hg-print-log (files buffer &optional shortlog limit)
+(defun vc-hg-print-log (files buffer &optional shortlog limit start-revision)
   "Get change log associated with FILES."
   ;; `vc-do-command' creates the buffer, but we need it before running
   ;; the command.
@@ -231,6 +235,7 @@ If nil, use the value of `vc-diff-switch
 	buffer
       (apply 'vc-hg-command buffer 0 files "log"
 	     (append
+	      (when start-revision (list (format "-r%s:" start-revision)))
 	      (when limit (list "-l" (format "%s" limit)))
 	      (when shortlog '("--style" "compact"))
 	      vc-hg-log-switches)))))




  parent reply	other threads:[~2009-12-06 17:43 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-12 23:19 limit the number of log entries displayed by C-x v l Dan Nicolaescu
2009-11-13  1:18 ` Stefan Monnier
2009-11-13  2:21   ` Dan Nicolaescu
2009-11-13  3:19     ` Stefan Monnier
2009-11-13  5:02       ` Dan Nicolaescu
2009-11-13 14:10         ` Stefan Monnier
2009-11-15 20:55           ` Dan Nicolaescu
2009-11-15 21:34             ` Chong Yidong
2009-11-16  9:40             ` Dan Nicolaescu
2009-11-16 14:22               ` Stefan Monnier
2009-11-16 15:10                 ` Dan Nicolaescu
2009-11-16 15:41                   ` Stefan Monnier
2009-11-16 20:40                     ` Dan Nicolaescu
2009-11-17 13:44           ` Dan Nicolaescu
2009-11-17 19:54             ` Stefan Monnier
2009-11-18 18:19               ` Dan Nicolaescu
2009-11-19  0:52                 ` Stefan Monnier
2009-11-19  7:23                   ` Thierry Volpiatto
2009-11-20  6:59                     ` Dan Nicolaescu
2009-11-20  7:19                       ` Thierry Volpiatto
2009-11-20 14:11                       ` Stefan Monnier
2009-11-20 15:26                         ` Dan Nicolaescu
2009-11-21  4:27                           ` Stephen J. Turnbull
2009-11-22 20:12                             ` Stefan Monnier
2009-11-22 23:02                               ` Štěpán Němec
2009-11-23  2:29                                 ` Stefan Monnier
2009-11-23  3:49                                   ` Bob Rogers
2009-11-23  5:17                                     ` Stefan Monnier
2009-11-22 20:10                           ` Stefan Monnier
2009-12-06 17:43                   ` Dan Nicolaescu [this message]
2009-12-07  2:12                     ` Stefan Monnier
2009-11-13  6:59     ` Giorgos Keramidas
2009-11-14 10:10 ` Alfred M. Szmidt
2009-11-14 23:29   ` Richard Stallman
2009-11-14 23:34     ` Andreas Schwab
2009-11-15 22:38       ` Richard Stallman
2009-11-15 22:52         ` Andreas Schwab
2009-11-17  7:56           ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200912061743.nB6HhWU0029917@godzilla.ics.uci.edu \
    --to=dann@ics.uci.edu \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).