comparison lisp/vc-git.el @ 105010:b3c2589ed19e

* vc.el (top): print-log method now takes an optional SHORTLOG argument. Add a new method: root. * vc-hooks.el (vc-prefix-map, vc-menu-map): Add bindings for vc-print-root-log and vc-print-root-diff. * vc-bzr.el (vc-bzr-log-view-mode, vc-bzr-print-log): * vc-git.el (vc-git-print-log, vc-git-log-view-mode): * vc-hg.el (vc-hg-print-log, vc-hg-log-view-mode): Add support for short logs. * vc-cvs.el (vc-cvs-print-log): * vc-mtn.el (vc-mtn-print-log): * vc-rcs.el (vc-rcs-print-log): * vc-sccs.el (vc-sccs-print-log): * vc-svn.el (vc-svn-print-log): Add an optional argument shortlog that is ignored for now.
author Dan Nicolaescu <dann@ics.uci.edu>
date Mon, 14 Sep 2009 04:38:49 +0000
parents 7aab0a4e4fcd
children bfda253c8f66
comparison
equal deleted inserted replaced
105009:b520d55cdd72 105010:b3c2589ed19e
469 (vc-git-command nil 0 file "update-index" "--") 469 (vc-git-command nil 0 file "update-index" "--")
470 (vc-git-command nil 0 file "checkout" "HEAD"))) 470 (vc-git-command nil 0 file "checkout" "HEAD")))
471 471
472 ;;; HISTORY FUNCTIONS 472 ;;; HISTORY FUNCTIONS
473 473
474 (defun vc-git-print-log (files &optional buffer) 474 (defun vc-git-print-log (files &optional buffer shortlog)
475 "Get change log associated with FILES." 475 "Get change log associated with FILES."
476 (let ((coding-system-for-read git-commits-coding-system) 476 (let ((coding-system-for-read git-commits-coding-system)
477 ;; Support both the old print-log interface that passes a 477 ;; Support both the old print-log interface that passes a
478 ;; single file, and the new one that passes a file list. 478 ;; single file, and the new one that passes a file list.
479 (flist (if (listp files) files (list files)))) 479 (flist (if (listp files) files (list files))))
483 ;; If the buffer exists from a previous invocation it might be 483 ;; If the buffer exists from a previous invocation it might be
484 ;; read-only. 484 ;; read-only.
485 (let ((inhibit-read-only t)) 485 (let ((inhibit-read-only t))
486 (with-current-buffer 486 (with-current-buffer
487 buffer 487 buffer
488 (if shortlog
488 (vc-git-command buffer 'async files 489 (vc-git-command buffer 'async files
489 "rev-list" "--pretty" "HEAD" "--"))))) 490 "log" ;; "--graph"
491 "--date=short" "--pretty=format:%h %ad %s" "--abbrev-commit"
492 "--")
493 (vc-git-command buffer 'async files
494 "rev-list" ;; "--graph"
495 "--pretty" "HEAD" "--"))))))
490 496
491 (defvar log-view-message-re) 497 (defvar log-view-message-re)
492 (defvar log-view-file-re) 498 (defvar log-view-file-re)
493 (defvar log-view-font-lock-keywords) 499 (defvar log-view-font-lock-keywords)
494 (defvar log-view-per-file-logs) 500 (defvar log-view-per-file-logs)
501
502 ;; Dynamically bound.
503 (defvar vc-short-log)
495 504
496 (define-derived-mode vc-git-log-view-mode log-view-mode "Git-Log-View" 505 (define-derived-mode vc-git-log-view-mode log-view-mode "Git-Log-View"
497 (require 'add-log) ;; we need the faces add-log 506 (require 'add-log) ;; we need the faces add-log
498 ;; Don't have file markers, so use impossible regexp. 507 ;; Don't have file markers, so use impossible regexp.
499 (set (make-local-variable 'log-view-file-re) "\\`a\\`") 508 (set (make-local-variable 'log-view-file-re) "\\`a\\`")
500 (set (make-local-variable 'log-view-per-file-logs) nil) 509 (set (make-local-variable 'log-view-per-file-logs) nil)
501 (set (make-local-variable 'log-view-message-re) 510 (set (make-local-variable 'log-view-message-re)
502 "^commit *\\([0-9a-z]+\\)") 511 (if vc-short-log
512 "^\\(?:[*/\\| ]+ \\)?\\([0-9a-z]+\\) \\([-a-z0-9]+\\) \\(.*\\)"
513 "^[ */\\|]+commit *\\([0-9a-z]+\\)"))
503 (set (make-local-variable 'log-view-font-lock-keywords) 514 (set (make-local-variable 'log-view-font-lock-keywords)
515 (if vc-short-log
516 (append
517 `((,log-view-message-re
518 (1 'change-log-acknowledgement)
519 (2 'change-log-date))))
504 (append 520 (append
505 `((,log-view-message-re (1 'change-log-acknowledgement))) 521 `((,log-view-message-re (1 'change-log-acknowledgement)))
506 ;; Handle the case: 522 ;; Handle the case:
507 ;; user: foo@bar 523 ;; user: foo@bar
508 '(("^Author:[ \t]+\\([A-Za-z0-9_.+-]+@[A-Za-z0-9_.-]+\\)" 524 '(("^Author:[ \t]+\\([A-Za-z0-9_.+-]+@[A-Za-z0-9_.-]+\\)"
519 (2 'change-log-email)) 535 (2 'change-log-email))
520 ("^Merge: \\([0-9a-z]+\\) \\([0-9a-z]+\\)" 536 ("^Merge: \\([0-9a-z]+\\) \\([0-9a-z]+\\)"
521 (1 'change-log-acknowledgement) 537 (1 'change-log-acknowledgement)
522 (2 'change-log-acknowledgement)) 538 (2 'change-log-acknowledgement))
523 ("^Date: \\(.+\\)" (1 'change-log-date)) 539 ("^Date: \\(.+\\)" (1 'change-log-date))
524 ("^summary:[ \t]+\\(.+\\)" (1 'log-view-message)))))) 540 ("^summary:[ \t]+\\(.+\\)" (1 'log-view-message)))))))
541
525 542
526 (defun vc-git-show-log-entry (revision) 543 (defun vc-git-show-log-entry (revision)
527 "Move to the log entry for REVISION. 544 "Move to the log entry for REVISION.
528 REVISION may have the form BRANCH, BRANCH~N, 545 REVISION may have the form BRANCH, BRANCH~N,
529 or BRANCH^ (where \"^\" can be repeated)." 546 or BRANCH^ (where \"^\" can be repeated)."
675 map)) 692 map))
676 693
677 (defun vc-git-extra-menu () vc-git-extra-menu-map) 694 (defun vc-git-extra-menu () vc-git-extra-menu-map)
678 695
679 (defun vc-git-extra-status-menu () vc-git-extra-menu-map) 696 (defun vc-git-extra-status-menu () vc-git-extra-menu-map)
697
698 (defun vc-git-root (file)
699 (vc-find-root file ".git"))
680 700
681 (defun vc-git-toggle-signoff () 701 (defun vc-git-toggle-signoff ()
682 (interactive) 702 (interactive)
683 (setq vc-git-add-signoff (not vc-git-add-signoff))) 703 (setq vc-git-add-signoff (not vc-git-add-signoff)))
684 704
761 "^stash@" "" (vc-git--run-command-string nil "stash" "list")))) 781 "^stash@" "" (vc-git--run-command-string nil "stash" "list"))))
762 782
763 783
764 ;;; Internal commands 784 ;;; Internal commands
765 785
766 (defun vc-git-root (file)
767 (vc-find-root file ".git"))
768
769 (defun vc-git-command (buffer okstatus file-or-list &rest flags) 786 (defun vc-git-command (buffer okstatus file-or-list &rest flags)
770 "A wrapper around `vc-do-command' for use in vc-git.el. 787 "A wrapper around `vc-do-command' for use in vc-git.el.
771 The difference to vc-do-command is that this function always invokes `git'." 788 The difference to vc-do-command is that this function always invokes `git'."
772 (apply 'vc-do-command (or buffer "*vc*") okstatus "git" file-or-list flags)) 789 (apply 'vc-do-command (or buffer "*vc*") okstatus "git" file-or-list flags))
773 790