From: Dan Nicolaescu <dann@ics.uci.edu>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: VC command for showing outgoing changes
Date: Fri, 1 Jan 2010 10:56:32 -0800 (PST) [thread overview]
Message-ID: <201001011856.o01IuWea015397@godzilla.ics.uci.edu> (raw)
In-Reply-To: <jwvy6lflhjj.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sun, 06 Dec 2009 20:40:27 -0500")
Stefan Monnier <monnier@iro.umontreal.ca> 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
prev parent reply other threads:[~2010-01-01 18:56 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-13 20:24 VC command for showing outgoing changes Dan Nicolaescu
2009-10-13 20:52 ` Stefan Monnier
2009-10-13 21:15 ` Dan Nicolaescu
2009-10-13 21:24 ` Giorgos Keramidas
2009-10-14 2:10 ` Stefan Monnier
2009-12-05 19:45 ` Dan Nicolaescu
2009-12-05 19:52 ` Dan Nicolaescu
2009-12-05 20:53 ` Stefan Monnier
2009-12-05 21:35 ` Stefan Monnier
2009-12-06 3:28 ` Dan Nicolaescu
2009-12-06 8:33 ` Dan Nicolaescu
2009-12-07 1:40 ` Stefan Monnier
2009-12-07 9:06 ` Dan Nicolaescu
2010-01-01 18:56 ` Dan Nicolaescu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201001011856.o01IuWea015397@godzilla.ics.uci.edu \
--to=dann@ics.uci.edu \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.