emacs-devel
[Top][All Lists]
Advanced

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

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


From: Dan Nicolaescu
Subject: Re: limit the number of log entries displayed by C-x v l
Date: Tue, 17 Nov 2009 05:44:54 -0800 (PST)

Stefan Monnier <address@hidden> writes:

  > >> > With the proposed backend change that just needs
  > >> > vc-annotate-show-log-revision-at-line to pass a 1 as the last argument
  > >> > to vc-print-log-internal.
  > >> Assuming we retarget the `working-revision' argument to specify the
  > >> "starting" revision, I guess.  Yes, that could work.
  > > Actually, after looking a bit more we'd need more changes, the
  > > `working-revision' is not passed to the `print-log' VC method, so a bit
  > > more work would be needed for that :-(
  > > But this does not affect my original proposal, which is still needed.
  > 
  > Yes, I'm not opposing it, I'm just trying to get a better general
  > picture.  Some of the problems we may encounter is that some backends
  > don't support the `limit' argument.  Hopefully all those backends can
  > easily turn a "print-log FILE REV LIMIT=1" request into "print-log FILE
  > REV1 REV2" instead, tho.  Not sure what to do for other values of LIMIT,
  > but maybe that's doable as well.

Here's a patch that implements only showing a single log entry from
vc-annotate.
It adds a START-REVISION argument to the print-log VC method.
It adds a boolean argument to vc-print-log-internal, when set it means
that the WORKING-REVISION argument is the start revision.

What do you think?

Index: vc-annotate.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/vc-annotate.el,v
retrieving revision 1.10
diff -u -3 -p -r1.10 vc-annotate.el
--- vc-annotate.el      19 Oct 2009 05:04:28 -0000      1.10
+++ vc-annotate.el      17 Nov 2009 13:35:55 -0000
@@ -487,7 +487,7 @@ Return a cons (REV . FILENAME)."
       (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))))))
+        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.85
diff -u -3 -p -r1.85 vc-bzr.el
--- vc-bzr.el   15 Nov 2009 20:29:01 -0000      1.85
+++ vc-bzr.el   17 Nov 2009 13:35:55 -0000
@@ -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.
@@ -493,11 +493,13 @@ REV non-nil gets an error."
   ;; way of getting the above regexps working.
   (with-current-buffer buffer
     (apply 'vc-bzr-command "log" buffer 'async files
-          (when shortlog "--short")
-          (when limit (list "-l" (format "%s" limit)))
-          (if (stringp vc-bzr-log-switches)
-              (list vc-bzr-log-switches)
-            vc-bzr-log-switches))))
+          (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)
+             vc-bzr-log-switches)))))
 
 (defun vc-bzr-show-log-entry (revision)
   "Find entry for patch name REVISION in bzr change log buffer."
Index: vc.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/vc.el,v
retrieving revision 1.740
diff -u -3 -p -r1.740 vc.el
--- vc.el       16 Nov 2009 20:36:11 -0000      1.740
+++ vc.el       17 Nov 2009 13:35:55 -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 ()
 ;;
@@ -1847,7 +1850,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 limit)
+(defun vc-print-log-internal (backend files working-revision 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.
@@ -1863,7 +1866,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*")
     (vc-exec-after
      `(let ((inhibit-read-only t)
@@ -1872,19 +1876,20 @@ Not all VC backends support short logs!"
        (set (make-local-variable 'log-view-vc-backend) ',backend)
        (set (make-local-variable 'log-view-vc-fileset) ',files)
 
-       (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))
@@ -1918,7 +1923,7 @@ If WORKING-REVISION is non-nil, leave th
         (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 limit)))
+    (vc-print-log-internal backend files working-revision limit nil)))
 
 ;;;###autoload
 (defun vc-print-root-log (&optional limit)
@@ -1943,7 +1948,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 ()




reply via email to

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