From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dan Nicolaescu Newsgroups: gmane.emacs.devel Subject: Re: VC command for showing outgoing changes Date: Fri, 1 Jan 2010 10:56:32 -0800 (PST) Message-ID: <201001011856.o01IuWea015397@godzilla.ics.uci.edu> References: <200910132024.n9DKOHGj015040@godzilla.ics.uci.edu> <200912051945.nB5Jjam5020140@godzilla.ics.uci.edu> <200912051952.nB5JqXSm020185@godzilla.ics.uci.edu> <200912060833.nB68XgjU025891@godzilla.ics.uci.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1262372311 9331 80.91.229.12 (1 Jan 2010 18:58:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 1 Jan 2010 18:58:31 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jan 01 19:58:23 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NQmha-0004iW-Ky for ged-emacs-devel@m.gmane.org; Fri, 01 Jan 2010 19:58:23 +0100 Original-Received: from localhost ([127.0.0.1]:37846 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NQmhb-0001wR-4Z for ged-emacs-devel@m.gmane.org; Fri, 01 Jan 2010 13:58:23 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NQmhV-0001vw-P0 for emacs-devel@gnu.org; Fri, 01 Jan 2010 13:58:17 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NQmhP-0001vI-Pc for emacs-devel@gnu.org; Fri, 01 Jan 2010 13:58:16 -0500 Original-Received: from [199.232.76.173] (port=54204 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NQmhP-0001v6-L9 for emacs-devel@gnu.org; Fri, 01 Jan 2010 13:58:11 -0500 Original-Received: from paul-mcgann-v0.ics.uci.edu ([128.195.1.147]:48615) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NQmhO-0005Yv-Uh for emacs-devel@gnu.org; Fri, 01 Jan 2010 13:58:11 -0500 Original-Received: from godzilla.ics.uci.edu (godzilla.ics.uci.edu [128.195.10.101]) by paul-mcgann-v0.ics.uci.edu (8.13.8/8.13.8) with ESMTP id o01IuWqI004730 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 1 Jan 2010 10:56:32 -0800 Original-Received: (from dann@localhost) by godzilla.ics.uci.edu (8.13.8+Sun/8.13.6/Submit) id o01IuWea015397; Fri, 1 Jan 2010 10:56:32 -0800 (PST) In-Reply-To: (Stefan Monnier's message of "Sun, 06 Dec 2009 20:40:27 -0500") Original-Lines: 207 X-ICS-MailScanner-Information: Please send mail to helpdesk@ics.uci.edu or more information X-ICS-MailScanner-ID: o01IuWqI004730 X-ICS-MailScanner: Found to be clean X-ICS-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=3.044, required 5, autolearn=disabled, ALL_TRUSTED -1.44, FH_DATE_PAST_20XX 3.38, FM_MULTI_ODD2 1.10) X-ICS-MailScanner-SpamScore: sss X-ICS-MailScanner-From: dann@godzilla.ics.uci.edu X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:119215 Archived-At: Stefan Monnier writes: > Your new patch looks closer, thanks. But we also still need to factor > out the commonality between vc-incoming-outgoing-internal and > vc-print-log-internal. Here's a new version that does that. OK? Index: vc.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/vc.el,v retrieving revision 1.746 diff -u -3 -p -u -p -r1.746 vc.el --- vc.el 7 Dec 2009 09:02:16 -0000 1.746 +++ vc.el 1 Jan 2010 18:51:19 -0000 @@ -344,6 +344,16 @@ ;; revision. At this point START-REVISION is only required to work ;; in conjunction with LIMIT = 1. ;; +;; * log-outgoing (backend remote-location) +;; +;; Insert in BUFFER the revision log for the changes that will be +;; sent when performing a push operation to REMOTE-LOCATION. +;; +;; * log-incoming (backend remote-location) +;; +;; Insert in BUFFER the revision log for the changes that will be +;; received when performing a pull operation from REMOTE-LOCATION. +;; ;; - log-view-mode () ;; ;; Mode to use for the output of print-log. This defaults to @@ -1865,13 +1875,34 @@ Not all VC backends support short logs!" (defvar log-view-vc-backend) (defvar log-view-vc-fileset) +(defun vc-print-log-setup-buttons (working-revision is-start-revision limit pl-return) + (when (and limit (not (eq 'limit-unsupported pl-return)) + (not is-start-revision)) + (goto-char (point-max)) + (lexical-let ((working-revision working-revision)) + (widget-create 'push-button + :notify (lambda (&rest ignore) + (vc-print-log-internal + log-view-vc-backend log-view-vc-fileset + working-revision nil (* 2 limit))) + :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 + log-view-vc-backend log-view-vc-fileset + working-revision nil nil)) + :help-echo "Show the log again, showing all entries" + "Show unlimited entries")) + (widget-setup))) + (defun vc-print-log-internal (backend files working-revision - &optional is-start-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. + &optional is-start-revision limit) (let ((dir-present nil) (vc-short-log nil) + (buffer-name "*vc-change-log*") + type pl-return) (dolist (file files) (when (file-directory-p file) @@ -1880,44 +1911,58 @@ Not all VC backends support short logs!" (not (null (if dir-present (memq 'directory vc-log-short-style) (memq 'file vc-log-short-style))))) - - (setq pl-return (vc-call-backend - backend 'print-log files "*vc-change-log*" - vc-short-log (when is-start-revision working-revision) limit)) - (pop-to-buffer "*vc-change-log*") + (setq type (if vc-short-log 'short 'long)) + (lexical-let + ((working-revision working-revision) + (limit limit) + (shortlog vc-short-log) + (is-start-revision is-start-revision)) + (vc-log-internal-common + backend buffer-name files type + (lambda (bk buf type-arg files-arg) + (vc-call-backend bk 'print-log files-arg buf + shortlog (when is-start-revision working-revision) limit)) + (lambda (bk files-arg ret) + (vc-print-log-setup-buttons working-revision + is-start-revision limit ret)) + (lambda (bk) + (vc-call-backend bk 'show-log-entry working-revision)))))) + +(defun vc-log-internal-common (backend + buffer-name + files + type + backend-func + setup-buttons-func + goto-location-func) + (let (retval) + (with-current-buffer (get-buffer-create buffer-name) + (set (make-local-variable 'log-view-type) type)) + (setq retval (funcall backend-func backend buffer-name type files)) + (pop-to-buffer buffer-name) (let ((inhibit-read-only t)) - ;; log-view-mode used to be called with inhibit-read-only bound - ;; to t, so let's keep doing it, just in case. - (vc-call-backend backend 'log-view-mode)) - (set (make-local-variable 'log-view-vc-backend) backend) - (set (make-local-variable 'log-view-vc-fileset) files) - + (vc-call-backend backend 'log-view-mode) + (set (make-local-variable 'log-view-vc-backend) backend) + (set (make-local-variable 'log-view-vc-fileset) files)) (vc-exec-after `(let ((inhibit-read-only t)) - (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 nil (* 2 ,limit))) - :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 nil)) - :help-echo "Show the log again, showing all entries" - "Show unlimited entries") - (widget-setup)) - + (funcall ',setup-buttons-func ',backend ',files ',retval) (shrink-window-if-larger-than-buffer) - ;; move point to the log entry for the working revision - (vc-call-backend ',backend 'show-log-entry ',working-revision) + (funcall ',goto-location-func ',backend) (setq vc-sentinel-movepoint (point)) (set-buffer-modified-p nil))))) +(defun vc-incoming-outgoing-internal (backend remote-location buffer-name type) + (vc-log-internal-common + backend buffer-name nil type + (lexical-let + ((remote-location remote-location)) + (lambda (bk buf type-arg files) + (vc-call-backend bk type-arg buf remote-location))) + (lambda (bk files-arg ret)) + (lambda (bk) + (goto-char (point-min))))) + ;;;###autoload (defun vc-print-log (&optional working-revision limit) "List the change log of the current fileset in a window. @@ -1938,10 +1983,10 @@ If WORKING-REVISION is non-nil, leave th (t (list nil (when (> vc-log-show-limit 0) vc-log-show-limit))))) (let* ((vc-fileset (vc-deduce-fileset t)) ;FIXME: Why t? --Stef - (backend (car vc-fileset)) + (backend5 (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 nil limit))) + (vc-print-log-internal backend5 files working-revision nil limit))) ;;;###autoload (defun vc-print-root-log (&optional limit) @@ -1970,6 +2015,32 @@ If WORKING-REVISION is non-nil, leave th (vc-print-log-internal backend (list rootdir) working-revision nil limit))) ;;;###autoload +(defun vc-log-incoming (&optional remote-location) + "Show a log of changes that will be received with a pull operation from REMOTE-LOCATION." + (interactive "sRemote location (empty for default): ") + (let ((backend + (cond ((derived-mode-p 'vc-dir-mode) vc-dir-backend) + ((derived-mode-p 'dired-mode) (vc-responsible-backend default-directory)) + (vc-mode (vc-backend buffer-file-name)))) + rootdir working-revision) + (unless backend + (error "Buffer is not version controlled")) + (vc-incoming-outgoing-internal backend remote-location "*vc-incoming*" 'log-incoming))) + +;;;###autoload +(defun vc-log-outgoing (&optional remote-location) + "Show a log of changes that will be sent with a push operation to REMOTE-LOCATION." + (interactive "sRemote location (empty for default): ") + (let ((backend + (cond ((derived-mode-p 'vc-dir-mode) vc-dir-backend) + ((derived-mode-p 'dired-mode) (vc-responsible-backend default-directory)) + (vc-mode (vc-backend buffer-file-name)))) + rootdir working-revision) + (unless backend + (error "Buffer is not version controlled")) + (vc-incoming-outgoing-internal backend remote-location "*vc-outgoing*" 'log-outgoing))) + +;;;###autoload (defun vc-revert () "Revert working copies of the selected fileset to their repository contents. This asks for confirmation if the buffer contents are not identical