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: Sat, 5 Dec 2009 11:52:33 -0800 (PST) Message-ID: <200912051952.nB5JqXSm020185@godzilla.ics.uci.edu> References: <200910132024.n9DKOHGj015040@godzilla.ics.uci.edu> <200912051945.nB5Jjam5020140@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 1260042871 24989 80.91.229.12 (5 Dec 2009 19:54:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 5 Dec 2009 19:54: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 Sat Dec 05 20:54:24 2009 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 1NH0hy-00083Q-KH for ged-emacs-devel@m.gmane.org; Sat, 05 Dec 2009 20:54:24 +0100 Original-Received: from localhost ([127.0.0.1]:45865 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NH0hy-0004DU-Cf for ged-emacs-devel@m.gmane.org; Sat, 05 Dec 2009 14:54:22 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NH0ht-0004DH-I7 for emacs-devel@gnu.org; Sat, 05 Dec 2009 14:54:17 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NH0ho-0004Cp-Im for emacs-devel@gnu.org; Sat, 05 Dec 2009 14:54:17 -0500 Original-Received: from [199.232.76.173] (port=50869 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NH0ho-0004Cm-FG for emacs-devel@gnu.org; Sat, 05 Dec 2009 14:54:12 -0500 Original-Received: from colin-baker-v0.ics.uci.edu ([128.195.1.153]:56631) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NH0hn-0002oy-QZ for emacs-devel@gnu.org; Sat, 05 Dec 2009 14:54:12 -0500 Original-Received: from godzilla.ics.uci.edu (godzilla.ics.uci.edu [128.195.10.101]) by colin-baker-v0.ics.uci.edu (8.13.8/8.13.8) with ESMTP id nB5JqX5b029136 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 5 Dec 2009 11:52:33 -0800 Original-Received: (from dann@localhost) by godzilla.ics.uci.edu (8.13.8+Sun/8.13.6/Submit) id nB5JqXSm020185; Sat, 5 Dec 2009 11:52:33 -0800 (PST) In-Reply-To: <200912051945.nB5Jjam5020140@godzilla.ics.uci.edu> (Dan Nicolaescu's message of "Sat, 5 Dec 2009 11:45:36 -0800 (PST)") Original-Lines: 329 X-ICS-MailScanner-Information: Please send mail to helpdesk@ics.uci.edu or more information X-ICS-MailScanner-ID: nB5JqX5b029136 X-ICS-MailScanner: Found to be clean X-ICS-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-0.263, required 5, autolearn=disabled, ALL_TRUSTED -1.44, FM_MULTI_ODD2 1.10, TW_BZ 0.08) 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:118318 Archived-At: Dan Nicolaescu writes: > Stefan Monnier writes: > > > > It would be nice to have a VC command for showing the outgoing changes > > > for distributed VC systems (i.e. the log of the changes that will be > > > pushed when you do a VC push). > > > Let's call this method vc-outgoing (name suggestions are welcome). > > > > I think before that we should have support for a `push' backend operation. > > > > > vc-hg-outgoing does this, but it's only for mercurial, it would be good > > > to have a generic method for doing such a thing. > > > > Agreed. > > > > > One thing we can do is to create a log-view-base-mode and have > > > log-view-mode and log-view-outgoing-mode derive from this mode, and have > > > log-view-mode and log-view-outgoing-mode define their own commands and > > > key bindings. > > > > Since each backend typically creates its own vc--log-view-mode, > > that tend to lead to the need for "multiple inheritance" in > > define-derived-mode. Given the lack of support for such a monster right > > now, we should probably stick to something simpler, e.g. add > > a log-view-outgoing binary var, behaving kind of like a minor-mode and > > controlling availability of some extra bindings. > > Here's a patch that implements the generic vc-incoming, vc-outgoing and > implements the backend specific functions for bzr, hg and partially for > git (no incoming and outgoing is not quite right). > Showing diffs works. > What keys should we use? C-x v I and C-x v O ? > This will be useful when we switch to bzr... > > OK to check in? Oops, sorry, this time with the diff attached. Index: log-view.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/log-view.el,v retrieving revision 1.64 diff -u -3 -p -r1.64 log-view.el --- log-view.el 4 Dec 2009 16:34:27 -0000 1.64 +++ log-view.el 5 Dec 2009 19:34:55 -0000 @@ -238,6 +238,9 @@ The match group number 1 should match th (defvar log-view-vc-backend nil "Set this to the VC backend that created the current log.") +(defvar log-view-type nil + "Set this to differentiate the different types of logs.") + ;;;; ;;;; Actual code ;;;; @@ -246,6 +249,8 @@ The match group number 1 should match th (define-derived-mode log-view-mode special-mode "Log-View" "Major mode for browsing CVS log output." (setq buffer-read-only t) + (when (boundp 'vc-log-view-type) + (set (make-local-variable 'log-view-type) vc-log-view-type)) (set (make-local-variable 'font-lock-defaults) log-view-font-lock-defaults) (set (make-local-variable 'beginning-of-defun-function) 'log-view-beginning-of-defun) Index: vc.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/vc.el,v retrieving revision 1.745 diff -u -3 -p -r1.745 vc.el --- vc.el 3 Dec 2009 19:12:55 -0000 1.745 +++ vc.el 5 Dec 2009 19:34:55 -0000 @@ -341,6 +341,16 @@ ;; backend does not support limiting the number of entries to show ;; it should return `limit-unsupported'. ;; +;; * 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. +;; +;; * 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 @@ -1825,6 +1835,7 @@ checked out in that new branch." (when (file-directory-p dir) (setq dir (file-name-as-directory dir))) (vc-call-backend (vc-responsible-backend dir) 'create-tag dir name branchp) + (vc-resynch-buffers-in-directory dir vc-keep-workfiles t) (message "Making %s... done" (if branchp "branch" "tag"))) ;;;###autoload @@ -1845,6 +1856,8 @@ allowed and simply skipped)." (message "%s" msg) (vc-call-backend (vc-responsible-backend dir) 'retrieve-tag dir name update) + (when update + (vc-resynch-buffers-in-directory dir vc-keep-workfiles t)) (message "%s" (concat msg "done")))) ;; Miscellaneous other entry points @@ -1869,6 +1882,7 @@ Not all VC backends support short logs!" ;; buffer can be accessed by the command. (let ((dir-present nil) (vc-short-log nil) + vc-log-view-type pl-return) (dolist (file files) (when (file-directory-p file) @@ -1877,6 +1891,7 @@ 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 vc-log-view-type (if vc-short-log 'short 'long)) (setq pl-return (vc-call-backend backend 'print-log files "*vc-change-log*" vc-short-log limit)) @@ -1913,6 +1928,34 @@ Not all VC backends support short logs!" (setq vc-sentinel-movepoint (point)) (set-buffer-modified-p nil))))) +(defun vc-incoming-internal (backend remote-location) + (let ((buff-name "*vc-incoming*")) + (vc-call-backend backend 'incoming buff-name remote-location) + (pop-to-buffer buff-name) + (vc-exec-after + `(let ((inhibit-read-only t) + (vc-log-view-type 'incoming)) + (vc-call-backend ',backend 'log-view-mode) + (set (make-local-variable 'log-view-vc-backend) ',backend) + (set (make-local-variable 'log-view-vc-fileset) nil) + (shrink-window-if-larger-than-buffer) + (setq vc-sentinel-movepoint (point)) + (set-buffer-modified-p nil))))) + +(defun vc-outgoing-internal (backend remote-location) + (let ((buff-name "*vc-outgoing*")) + (vc-call-backend backend 'outgoing buff-name remote-location) + (pop-to-buffer buff-name) + (vc-exec-after + `(let ((inhibit-read-only t) + (vc-log-view-type 'outgoing)) + (vc-call-backend ',backend 'log-view-mode) + (set (make-local-variable 'log-view-vc-backend) ',backend) + (set (make-local-variable 'log-view-vc-fileset) nil) + (shrink-window-if-larger-than-buffer) + (setq vc-sentinel-movepoint (point)) + (set-buffer-modified-p nil))))) + ;;;###autoload (defun vc-print-log (&optional working-revision limit) "List the change log of the current fileset in a window. @@ -1965,6 +2008,32 @@ If WORKING-REVISION is non-nil, leave th (vc-print-log-internal backend (list rootdir) working-revision limit))) ;;;###autoload +(defun vc-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-internal backend remote-location))) + +;;;###autoload +(defun vc-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-outgoing-internal backend remote-location))) + +;;;###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 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 5 Dec 2009 19:34:55 -0000 @@ -239,18 +239,18 @@ If nil, use the value of `vc-diff-switch (defvar log-view-file-re) (defvar log-view-font-lock-keywords) (defvar log-view-per-file-logs) -(defvar vc-short-log) +(defvar log-view-type) (define-derived-mode vc-hg-log-view-mode log-view-mode "Hg-Log-View" (require 'add-log) ;; we need the add-log faces (set (make-local-variable 'log-view-file-re) "\\`a\\`") (set (make-local-variable 'log-view-per-file-logs) nil) (set (make-local-variable 'log-view-message-re) - (if vc-short-log + (if (eq log-view-type 'short) "^\\([0-9]+\\)\\(?:\\[.*\\]\\)? +\\([0-9a-z]\\{12\\}\\) +\\(\\(?:[0-9]+\\)-\\(?:[0-9]+\\)-\\(?:[0-9]+\\) \\(?:[0-9]+\\):\\(?:[0-9]+\\) \\(?:[-+0-9]+\\)\\) +\\(.*\\)$" "^changeset:[ \t]*\\([0-9]+\\):\\(.+\\)")) (set (make-local-variable 'log-view-font-lock-keywords) - (if vc-short-log + (if (eq log-view-type 'short) (append `((,log-view-message-re (1 'log-view-message-face) (2 'log-view-message-face) @@ -567,21 +567,11 @@ REV is the revision to check out into WO `("Hg-incoming" ["Pull selected" vc-hg-pull])) -(defun vc-hg-outgoing () - (interactive) - (let ((bname "*Hg outgoing*") - (vc-short-log nil)) - (vc-hg-command bname 1 nil "outgoing" "-n") - (pop-to-buffer bname) - (vc-hg-outgoing-mode))) +(defun vc-hg-incoming (buffer remote-location) + (vc-hg-command buffer 1 nil "incoming" "-n" remote-location)) -(defun vc-hg-incoming () - (interactive) - (let ((bname "*Hg incoming*") - (vc-short-log nil)) - (vc-hg-command bname 0 nil "incoming" "-n") - (pop-to-buffer bname) - (vc-hg-incoming-mode))) +(defun vc-hg-outgoing (buffer remote-location) + (vc-hg-command buffer 1 nil "outgoing" "-n" remote-location)) (declare-function log-view-get-marked "log-view" ()) Index: vc-git.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/vc-git.el,v retrieving revision 1.102 diff -u -3 -p -r1.102 vc-git.el --- vc-git.el 3 Dec 2009 04:08:12 -0000 1.102 +++ vc-git.el 5 Dec 2009 19:34:56 -0000 @@ -560,6 +560,16 @@ If nil, use the value of `vc-diff-switch "--pretty" "HEAD" "--"))) (when limit 'limit-unsupported)))) +(defun vc-git-outgoing (buffer remote-location) + (interactive) + (vc-git-command + buffer 0 nil + "log" "--date=short" "--pretty=format:%h %ad %s" "--abbrev-commit" + (if (string= remote-location "") + "origin/master..HEAD" + remote-location))) + + (defvar log-view-message-re) (defvar log-view-file-re) (defvar log-view-font-lock-keywords) @@ -574,11 +584,11 @@ If nil, use the value of `vc-diff-switch (set (make-local-variable 'log-view-file-re) "\\`a\\`") (set (make-local-variable 'log-view-per-file-logs) nil) (set (make-local-variable 'log-view-message-re) - (if vc-short-log + (if (memq log-view-type '(short outgoing)) "^\\(?:[*/\\| ]+ \\)?\\([0-9a-z]+\\) \\([-a-z0-9]+\\) \\(.*\\)" "^commit *\\([0-9a-z]+\\)")) (set (make-local-variable 'log-view-font-lock-keywords) - (if vc-short-log + (if (memq log-view-type '(short outgoing)) (append `((,log-view-message-re (1 'change-log-acknowledgement) 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 5 Dec 2009 19:34:56 -0000 @@ -453,7 +453,6 @@ REV non-nil gets an error." (defvar log-view-font-lock-keywords) (defvar log-view-current-tag-function) (defvar log-view-per-file-logs) -(defvar vc-short-log) (define-derived-mode vc-bzr-log-view-mode log-view-mode "Bzr-Log-View" (remove-hook 'log-view-mode-hook 'vc-bzr-log-view-mode) ;Deactivate the hack. @@ -461,13 +460,13 @@ REV non-nil gets an error." (set (make-local-variable 'log-view-per-file-logs) nil) (set (make-local-variable 'log-view-file-re) "\\`a\\`") (set (make-local-variable 'log-view-message-re) - (if vc-short-log + (if (eq log-view-type 'short) "^ +\\([0-9]+\\) \\(.*?\\)[ \t]+\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}\\)\\( \\[merge\\]\\)?" "^ *\\(?:revno: \\([0-9.]+\\)\\|merged: .+\\)")) (set (make-local-variable 'log-view-font-lock-keywords) ;; 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 + (if (eq log-view-type 'short) (append `((,log-view-message-re (1 'log-view-message-face) (2 'change-log-name) @@ -500,6 +499,14 @@ REV non-nil gets an error." (list vc-bzr-log-switches) vc-bzr-log-switches))))) +(defun vc-bzr-incoming (buffer remote-location) + (apply 'vc-bzr-command "missing" buffer 'async nil + (list "--theirs-only" (unless (string= remote-location "") remote-location)))) + +(defun vc-bzr-outgoing (buffer remote-location) + (apply 'vc-bzr-command "missing" buffer 'async nil + (list "--mine-only" (unless (string= remote-location "") remote-location)))) + (defun vc-bzr-show-log-entry (revision) "Find entry for patch name REVISION in bzr change log buffer." (goto-char (point-min))