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: Sun, 6 Dec 2009 09:43:32 -0800 (PST)

Stefan Monnier <address@hidden> 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)))))




reply via email to

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