all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dan Nicolaescu <dann@ics.uci.edu>
To: emacs-devel@gnu.org
Subject: limit the number of log entries displayed by C-x v l
Date: Thu, 12 Nov 2009 15:19:57 -0800 (PST)	[thread overview]
Message-ID: <200911122319.nACNJvUn006154@godzilla.ics.uci.edu> (raw)


Logs for some big trees can be huge, the Linux one is millions of
lines.  It would be nice if C-x v l could limit the number of items
displayed because it takes too long to compute, and very seldom anybody
wants to look at so many lines.

Modern VCS can limit the number of item displayed by using a command
line argument.  So the print-log VC method can be changed to do that,
Here's how to do that for Mercurial:

--- vc-hg.el.~1.105.~	2009-10-29 21:46:20.000000000 -0700
+++ vc-hg.el	2009-11-12 05:29:06.000000000 -0800
@@ -219,5 +219,5 @@ If nil, use the value of `vc-diff-switch
                  (repeat :tag "Argument List" :value ("") string))
   :group 'vc-hg)
 
-(defun vc-hg-print-log (files &optional buffer shortlog)
+(defun vc-hg-print-log (files &optional buffer shortlog limit)
   "Get change log associated with FILES."
@@ -236,7 +232,9 @@ If nil, use the value of `vc-diff-switch
       (apply 'vc-hg-command buffer 0 files "log"
 	     (if shortlog
                  (append '("--style" "compact") vc-hg-log-switches)
-                 vc-hg-log-switches)))))
+                 vc-hg-log-switches)
+	     (when limit
+	       (list "-l" limit))))))
 
 (defvar log-view-message-re)
 (defvar log-view-file-re)


One way to set the limit is to ask the user for a limit when using a
prefix argument so that it does not change the current default behavior,
like so:

--- vc.el.~1.738.~	2009-10-24 03:59:40.000000000 -0700
+++ vc.el	2009-11-12 06:35:20.000000000 -0800
@@ -1839,7 +1839,7 @@ If it contains `directory' then if the f
 If it contains `file' then show short logs for files.
 Not all VC backends support short logs!")
 
-(defun vc-print-log-internal (backend files working-revision)
+(defun vc-print-log-internal (backend files working-revision limit)
   ;; 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.
@@ -1852,7 +1852,7 @@ Not all VC backends support short logs!"
 	  (not (null (if dir-present
 			 (memq 'directory vc-log-short-style)
 		       (memq 'file vc-log-short-style)))))
-    (vc-call-backend backend 'print-log files "*vc-change-log*" vc-short-log)
+    (vc-call-backend backend 'print-log files "*vc-change-log*" vc-short-log limit)
     (pop-to-buffer "*vc-change-log*")
     (vc-exec-after
      `(let ((inhibit-read-only t)
@@ -1868,15 +1868,27 @@ Not all VC backends support short logs!"
 	(set-buffer-modified-p nil)))))
 
 ;;;###autoload
-(defun vc-print-log (&optional working-revision)
+(defun vc-print-log (&optional working-revision limit)
   "List the change log of the current fileset in a window.
 If WORKING-REVISION is non-nil, leave the point at that revision."
-  (interactive)
+  (interactive
+   (progn
+     (cond
+      (current-prefix-arg
+       (let ((rev (read-from-minibuffer "Log from revision (default: last revision): " nil
+				   nil nil nil))
+	     (lim (read-from-minibuffer "Limit display (default: unlimited): " ""
+				     nil nil nil)))
+	 (when (string= rev "") (setq rev nil))
+	 (when (string= lim "") (setq lim nil))
+	 (list rev lim)))
+      (t
+       (list nil nil)))))
   (let* ((vc-fileset (vc-deduce-fileset t)) ;FIXME: Why t? --Stef
 	 (backend (car vc-fileset))
 	 (files (cadr vc-fileset))
 	 (working-revision (or working-revision (vc-working-revision (car files)))))
-    (vc-print-log-internal backend files working-revision)))
+    (vc-print-log-internal backend files working-revision limit)))
 
 ;;;###autoload
 (defun vc-print-root-log ()
@@ -1890,7 +1902,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)))
+    (vc-print-log-internal backend (list rootdir) working-revision nil)))
 
 ;;;###autoload
 (defun vc-revert ()


Any reason not to check this in?

The backend part is straight forward, so that should be OK.
If some VCS does not support limiting, it can just ignore the argument.

Maybe we could limit the number of entries displayed by default, maybe a
few thousands?  But that's a separate issue...





             reply	other threads:[~2009-11-12 23:19 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-12 23:19 Dan Nicolaescu [this message]
2009-11-13  1:18 ` limit the number of log entries displayed by C-x v l 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
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

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

  git send-email \
    --in-reply-to=200911122319.nACNJvUn006154@godzilla.ics.uci.edu \
    --to=dann@ics.uci.edu \
    --cc=emacs-devel@gnu.org \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.