[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r103267: Add Log View toggle and log
From: |
Chong Yidong |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r103267: Add Log View toggle and log format customization for Git and Hg. |
Date: |
Sun, 13 Feb 2011 20:49:24 -0500 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 103267
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Sun 2011-02-13 20:49:24 -0500
message:
Add Log View toggle and log format customization for Git and Hg.
* lisp/vc/vc-git.el (vc-git-root-log-format): New option for
customizing log format.
(vc-git-print-log, vc-git-log-outgoing, vc-git-log-incoming)
(vc-git-log-view-mode): Use it.
(vc-git-expanded-log-entry): New function.
(vc-git-log-view-mode): Use it. Truncate lines in root log.
* lisp/vc/vc-hg.el (vc-hg-root-log-template): New option for
customizing log format.
(vc-hg-print-log): Use it.
(vc-hg-expanded-log-entry): New function.
(vc-hg-log-view-mode): Use vc-hg-root-log-template and
vc-hg-expanded-log-entry. Truncate lines in root log.
* lisp/vc/vc-bzr.el (vc-bzr-log-view-mode): Truncate lines in root log.
* lisp/vc/log-view.el (log-view-mode-menu): Add
log-view-toggle-entry-display.
modified:
etc/NEWS
lisp/ChangeLog
lisp/vc/log-view.el
lisp/vc/vc-bzr.el
lisp/vc/vc-git.el
lisp/vc/vc-hg.el
=== modified file 'etc/NEWS'
--- a/etc/NEWS 2011-02-13 20:04:33 +0000
+++ b/etc/NEWS 2011-02-14 01:49:24 +0000
@@ -606,14 +606,14 @@
This merges another branch into the current one. This command prompts
the user for specifics, e.g. a merge source.
-**** Currently supported by Bzr, Git, and Mercurial.
+**** Currently supported for Bzr, Git, and Mercurial.
*** Log entries in some Log View buffers can be toggled to display a
longer description by typing RET (log-view-toggle-entry-display).
In the Log View buffers made by `C-x v L' (vc-print-root-log), you can
use this to display the full log entry for the revision at point.
-**** Currently supported by Bzr.
+**** Currently supported for Bzr, Git, and Mercurial.
**** Packages using Log View mode can enable this functionality by
binding `log-view-expanded-log-entry-function' to a suitable function.
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2011-02-14 01:27:56 +0000
+++ b/lisp/ChangeLog 2011-02-14 01:49:24 +0000
@@ -1,3 +1,24 @@
+2011-02-14 Chong Yidong <address@hidden>
+
+ * vc/vc-git.el (vc-git-root-log-format): New option for
+ customizing log format.
+ (vc-git-print-log, vc-git-log-outgoing, vc-git-log-incoming)
+ (vc-git-log-view-mode): Use it.
+ (vc-git-expanded-log-entry): New function.
+ (vc-git-log-view-mode): Use it. Truncate lines in root log.
+
+ * vc/vc-hg.el (vc-hg-root-log-template): New option for
+ customizing log format.
+ (vc-hg-print-log): Use it.
+ (vc-hg-expanded-log-entry): New function.
+ (vc-hg-log-view-mode): Use vc-hg-root-log-template and
+ vc-hg-expanded-log-entry. Truncate lines in root log.
+
+ * vc/vc-bzr.el (vc-bzr-log-view-mode): Truncate lines in root log.
+
+ * vc/log-view.el (log-view-mode-menu): Add
+ log-view-toggle-entry-display.
+
2011-02-14 Glenn Morris <address@hidden>
* dired-x.el: Don't require man when compiling.
=== modified file 'lisp/vc/log-view.el'
--- a/lisp/vc/log-view.el 2011-02-13 20:04:33 +0000
+++ b/lisp/vc/log-view.el 2011-02-14 01:49:24 +0000
@@ -168,6 +168,8 @@
:help "Annotate the version at point"]
["Modify Log Comment" log-view-modify-change-comment
:help "Edit the change comment displayed at point"]
+ ["Toggle Details at Point" log-view-toggle-entry-display
+ :active log-view-expanded-log-entry-function]
"-----"
["Next Log Entry" log-view-msg-next
:help "Go to the next count'th log message"]
=== modified file 'lisp/vc/vc-bzr.el'
--- a/lisp/vc/vc-bzr.el 2011-02-13 20:04:33 +0000
+++ b/lisp/vc/vc-bzr.el 2011-02-14 01:49:24 +0000
@@ -603,6 +603,7 @@
"^ *\\(?:revno: \\([0-9.]+\\)\\|merged: .+\\)"))
;; Allow expanding short log entries
(when (eq vc-log-view-type 'short)
+ (setq truncate-lines t)
(set (make-local-variable 'log-view-expanded-log-entry-function)
'vc-bzr-expanded-log-entry))
(set (make-local-variable 'log-view-font-lock-keywords)
=== modified file 'lisp/vc/vc-git.el'
--- a/lisp/vc/vc-git.el 2011-01-29 21:19:21 +0000
+++ b/lisp/vc/vc-git.el 2011-02-14 01:49:24 +0000
@@ -119,6 +119,27 @@
:version "23.1"
:group 'vc)
+(defcustom vc-git-root-log-format
+ '("%d%h..: %an %ad %s"
+ ;; The first shy group matches the characters drawn by --graph.
+ ;; We use numbered groups because `log-view-message-re' wants the
+ ;; revision number to be group 1.
+ "^\\(?:[*/\\| ]+ \\)?\\(?2: ([^)]+)\\)?\\(?1:[0-9a-z]+\\)..: \
+\\(?3:.*?\\)[ \t]+\\(?4:[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}\\)"
+ ((1 'log-view-message-face)
+ (2 'change-log-list nil lax)
+ (3 'change-log-name)
+ (4 'change-log-date)))
+ "Git log format for `vc-print-root-log'.
+This should be a list (FORMAT REGEXP KEYWORDS), where FORMAT is a
+format string (which is passed to \"git log\" via the argument
+\"--pretty=tformat:FORMAT\"), REGEXP is a regular expression
+matching the resulting Git log output, and KEYWORDS is a list of
+`font-lock-keywords' for highlighting the Log View buffer."
+ :type '(list string string (repeat sexp))
+ :group 'vc
+ :version "24.1")
+
(defvar vc-git-commits-coding-system 'utf-8
"Default coding system for git commits.")
@@ -666,8 +687,10 @@
(append
'("log" "--no-color")
(when shortlog
- '("--graph" "--decorate" "--date=short"
- "--pretty=tformat:%d%h %ad %s" "--abbrev-commit"))
+ `("--graph" "--decorate" "--date=short"
+ ,(format "--pretty=tformat:%s"
+ (car vc-git-root-log-format))
+ "--abbrev-commit"))
(when limit (list "-n" (format "%s" limit)))
(when start-revision (list start-revision))
'("--")))))))
@@ -678,7 +701,8 @@
buffer 0 nil
"log"
"--no-color" "--graph" "--decorate" "--date=short"
- "--pretty=tformat:%d%h %ad %s" "--abbrev-commit"
+ (format "--pretty=tformat:%s" (car vc-git-root-log-format))
+ "--abbrev-commit"
(concat (if (string= remote-location "")
"@{upstream}"
remote-location)
@@ -689,9 +713,10 @@
(vc-git-command nil 0 nil "fetch")
(vc-git-command
buffer 0 nil
- "log"
+ "log"
"--no-color" "--graph" "--decorate" "--date=short"
- "--pretty=tformat:%d%h %ad %s" "--abbrev-commit"
+ (format "--pretty=tformat:%s" (car vc-git-root-log-format))
+ "--abbrev-commit"
(concat "HEAD.." (if (string= remote-location "")
"@{upstream}"
remote-location))))
@@ -700,6 +725,7 @@
(defvar log-view-file-re)
(defvar log-view-font-lock-keywords)
(defvar log-view-per-file-logs)
+(defvar log-view-expanded-log-entry-function)
(define-derived-mode vc-git-log-view-mode log-view-mode "Git-Log-View"
(require 'add-log) ;; We need the faces add-log.
@@ -708,37 +734,37 @@
(set (make-local-variable 'log-view-per-file-logs) nil)
(set (make-local-variable 'log-view-message-re)
(if (not (eq vc-log-view-type 'long))
- "^\\(?:[*/\\| ]+ \\)?\\(?: ([^)]+)\\)?\\([0-9a-z]+\\)
\\([-a-z0-9]+\\) \\(.*\\)"
+ (cadr vc-git-root-log-format)
"^commit *\\([0-9a-z]+\\)"))
+ ;; Allow expanding short log entries
+ (when (eq vc-log-view-type 'short)
+ (setq truncate-lines t)
+ (set (make-local-variable 'log-view-expanded-log-entry-function)
+ 'vc-git-expanded-log-entry))
(set (make-local-variable 'log-view-font-lock-keywords)
(if (not (eq vc-log-view-type 'long))
- '(
- ;; Same as log-view-message-re, except that we don't
- ;; want the shy group for the tag name.
- ("^\\(?:[*/\\| ]+ \\)?\\( ([^)]+)\\)?\\([0-9a-z]+\\)
\\([-a-z0-9]+\\) \\(.*\\)"
- (1 'highlight nil lax)
- (2 'change-log-acknowledgement)
- (3 'change-log-date)))
- (append
- `((,log-view-message-re (1 'change-log-acknowledgement)))
- ;; Handle the case:
- ;; user: address@hidden
- '(("^Author:[ \t]+\\(address@hidden)"
- (1 'change-log-email))
- ;; Handle the case:
- ;; user: FirstName LastName <address@hidden>
- ("^Author:[ \t]+\\([^<(]+?\\)[ \t]*[(<]\\(address@hidden)[>)]"
- (1 'change-log-name)
- (2 'change-log-email))
- ("^ +\\(?:\\(?:[Aa]cked\\|[Ss]igned-[Oo]ff\\)-[Bb]y:\\)[
\t]+\\(address@hidden)"
- (1 'change-log-name))
- ("^ +\\(?:\\(?:[Aa]cked\\|[Ss]igned-[Oo]ff\\)-[Bb]y:\\)[
\t]+\\([^<(]+?\\)[ \t]*[(<]\\(address@hidden)[>)]"
- (1 'change-log-name)
- (2 'change-log-email))
- ("^Merge: \\([0-9a-z]+\\) \\([0-9a-z]+\\)"
- (1 'change-log-acknowledgement)
- (2 'change-log-acknowledgement))
- ("^Date: \\(.+\\)" (1 'change-log-date))
+ (list (cons (nth 1 vc-git-root-log-format)
+ (nth 2 vc-git-root-log-format)))
+ (append
+ `((,log-view-message-re (1 'change-log-acknowledgement)))
+ ;; Handle the case:
+ ;; user: address@hidden
+ '(("^Author:[ \t]+\\(address@hidden)"
+ (1 'change-log-email))
+ ;; Handle the case:
+ ;; user: FirstName LastName <address@hidden>
+ ("^Author:[ \t]+\\([^<(]+?\\)[ \t]*[(<]\\(address@hidden)[>)]"
+ (1 'change-log-name)
+ (2 'change-log-email))
+ ("^ +\\(?:\\(?:[Aa]cked\\|[Ss]igned-[Oo]ff\\)-[Bb]y:\\)[
\t]+\\(address@hidden)"
+ (1 'change-log-name))
+ ("^ +\\(?:\\(?:[Aa]cked\\|[Ss]igned-[Oo]ff\\)-[Bb]y:\\)[
\t]+\\([^<(]+?\\)[ \t]*[(<]\\(address@hidden)[>)]"
+ (1 'change-log-name)
+ (2 'change-log-email))
+ ("^Merge: \\([0-9a-z]+\\) \\([0-9a-z]+\\)"
+ (1 'change-log-acknowledgement)
+ (2 'change-log-acknowledgement))
+ ("^Date: \\(.+\\)" (1 'change-log-date))
("^summary:[ \t]+\\(.+\\)" (1 'log-view-message)))))))
@@ -758,6 +784,15 @@
(t nil))))
(beginning-of-line)))
+(defun vc-git-expanded-log-entry (revision)
+ (with-temp-buffer
+ (apply 'vc-git-command t nil nil (list "log" revision "-1"))
+ (goto-char (point-min))
+ (unless (eobp)
+ ;; Indent the expanded log entry.
+ (indent-region (point-min) (point-max) 2)
+ (buffer-string))))
+
(defun vc-git-diff (files &optional rev1 rev2 buffer)
"Get a difference report using Git between two revisions of FILES."
(let (process-file-side-effects)
=== modified file 'lisp/vc/vc-hg.el'
--- a/lisp/vc/vc-hg.el 2011-02-03 07:33:16 +0000
+++ b/lisp/vc/vc-hg.el 2011-02-14 01:49:24 +0000
@@ -138,6 +138,24 @@
"Name of the Mercurial executable (excluding any arguments)."
:type 'string
:group 'vc)
+
+(defcustom vc-hg-root-log-format
+ '("{rev}:{tags}: {author|person} {date|shortdate} {desc|firstline}\\n"
+ "^\\([0-9]+\\):\\([^:]*\\): \\(.*?\\)[
\t]+\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}\\)"
+ ((1 'log-view-message-face)
+ (2 'change-log-list)
+ (3 'change-log-name)
+ (4 'change-log-date)))
+ "Mercurial log template for `vc-print-root-log'.
+This should be a list (TEMPLATE REGEXP KEYWORDS), where TEMPLATE
+is the \"--template\" argument string to pass to Mercurial,
+REGEXP is a regular expression matching the resulting Mercurial
+output, and KEYWORDS is a list of `font-lock-keywords' for
+highlighting the Log View buffer."
+ :type '(list string string (repeat sexp))
+ :group 'vc
+ :version "24.1")
+
;;; Properties of the backend
@@ -266,13 +284,14 @@
(nconc
(when start-revision (list (format "-r%s:" start-revision)))
(when limit (list "-l" (format "%s" limit)))
- (when shortlog (list "--style" "compact"))
+ (when shortlog (list "--template" (car vc-hg-root-log-format)))
vc-hg-log-switches)))))
(defvar log-view-message-re)
(defvar log-view-file-re)
(defvar log-view-font-lock-keywords)
(defvar log-view-per-file-logs)
+(defvar log-view-expanded-log-entry-function)
(define-derived-mode vc-hg-log-view-mode log-view-mode "Hg-Log-View"
(require 'add-log) ;; we need the add-log faces
@@ -280,33 +299,34 @@
(set (make-local-variable 'log-view-per-file-logs) nil)
(set (make-local-variable 'log-view-message-re)
(if (eq vc-log-view-type 'short)
- "^\\([0-9]+\\)\\(\\[.*\\]\\)? +\\([0-9a-z]\\{12\\}\\)
+\\(\\(?:[0-9]+\\)-\\(?:[0-9]+\\)-\\(?:[0-9]+\\) \\(?:[0-9]+\\):\\(?:[0-9]+\\)
\\(?:[-+0-9]+\\)\\) +\\(.*\\)$"
+ (cadr vc-hg-root-log-format)
"^changeset:[ \t]*\\([0-9]+\\):\\(.+\\)"))
+ ;; Allow expanding short log entries
+ (when (eq vc-log-view-type 'short)
+ (setq truncate-lines t)
+ (set (make-local-variable 'log-view-expanded-log-entry-function)
+ 'vc-hg-expanded-log-entry))
(set (make-local-variable 'log-view-font-lock-keywords)
(if (eq vc-log-view-type 'short)
- (append `((,log-view-message-re
- (1 'log-view-message-face)
- (2 'highlight nil lax)
- (3 'log-view-message-face)
- (4 'change-log-date)
- (5 'change-log-name))))
- (append
- log-view-font-lock-keywords
- '(
- ;; Handle the case:
- ;; user: FirstName LastName <address@hidden>
- ("^user:[ \t]+\\([^<(]+?\\)[ \t]*[(<]\\(address@hidden)[>)]"
- (1 'change-log-name)
- (2 'change-log-email))
- ;; Handle the cases:
- ;; user: address@hidden
- ;; and
- ;; user: foo
- ("^user:[ \t]+\\([A-Za-z0-9_.+-]+\\(?:@[A-Za-z0-9_.-]+\\)?\\)"
- (1 'change-log-email))
- ("^date: \\(.+\\)" (1 'change-log-date))
- ("^tag: +\\([^ ]+\\)$" (1 'highlight))
- ("^summary:[ \t]+\\(.+\\)" (1 'log-view-message)))))))
+ (list (cons (nth 1 vc-hg-root-log-format)
+ (nth 2 vc-hg-root-log-format)))
+ (append
+ log-view-font-lock-keywords
+ '(
+ ;; Handle the case:
+ ;; user: FirstName LastName <address@hidden>
+ ("^user:[ \t]+\\([^<(]+?\\)[ \t]*[(<]\\(address@hidden)[>)]"
+ (1 'change-log-name)
+ (2 'change-log-email))
+ ;; Handle the cases:
+ ;; user: address@hidden
+ ;; and
+ ;; user: foo
+ ("^user:[ \t]+\\([A-Za-z0-9_.+-]+\\(?:@[A-Za-z0-9_.-]+\\)?\\)"
+ (1 'change-log-email))
+ ("^date: \\(.+\\)" (1 'change-log-date))
+ ("^tag: +\\([^ ]+\\)$" (1 'highlight))
+ ("^summary:[ \t]+\\(.+\\)" (1 'log-view-message)))))))
(defun vc-hg-diff (files &optional oldvers newvers buffer)
"Get a difference report using hg between two revisions of FILES."
@@ -324,6 +344,16 @@
(list "-r" oldvers "-r" newvers)
(list "-r" oldvers)))))))
+(defun vc-hg-expanded-log-entry (revision)
+ (with-temp-buffer
+ (vc-hg-command t nil nil "log" "-r" revision)
+ (goto-char (point-min))
+ (unless (eobp)
+ ;; Indent the expanded log entry.
+ (indent-region (point-min) (point-max) 2)
+ (goto-char (point-max))
+ (buffer-string))))
+
(defun vc-hg-revision-table (files)
(let ((default-directory (file-name-directory (car files))))
(with-temp-buffer
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r103267: Add Log View toggle and log format customization for Git and Hg.,
Chong Yidong <=