[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

limit the number of log entries displayed by C-x v l

From: Dan Nicolaescu
Subject: limit the number of log entries displayed by C-x v l
Date: Thu, 12 Nov 2009 15:19:57 -0800 (PST)

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 
     (pop-to-buffer "*vc-change-log*")
      `(let ((inhibit-read-only t)
@@ -1868,15 +1868,27 @@ Not all VC backends support short logs!"
        (set-buffer-modified-p nil)))))
-(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 
-    (vc-print-log-internal backend files working-revision)))
+    (vc-print-log-internal backend files working-revision limit)))
 (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)))
 (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 via email to

[Prev in Thread] Current Thread [Next in Thread]