* VC command for showing outgoing changes
@ 2009-10-13 20:24 Dan Nicolaescu
2009-10-13 20:52 ` Stefan Monnier
0 siblings, 1 reply; 14+ messages in thread
From: Dan Nicolaescu @ 2009-10-13 20:24 UTC (permalink / raw)
To: emacs-devel
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).
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.
vc-print-log uses modes derived from log-view-mode.
vc-outgoing cannot quite use that because most commands that are defined
for log-view-mode do not make sense (annotate, next/previous file, show
version).
Some commands that would make sense for vc-outgoing: show the diff,
push, create a bundle, send by email.
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.
Something similar can be done for incoming changes.
Ideas, opinions, suggestions etc are welcome (code would be even better).
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: VC command for showing outgoing changes
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-12-05 19:45 ` Dan Nicolaescu
0 siblings, 2 replies; 14+ messages in thread
From: Stefan Monnier @ 2009-10-13 20:52 UTC (permalink / raw)
To: Dan Nicolaescu; +Cc: emacs-devel
> 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.
> vc-outgoing cannot quite use that because most commands that are defined
> for log-view-mode do not make sense (annotate, next/previous file, show
> version).
The next/previous file seem to make just as much (or as little) sense
for this as for log-view. Also, why don't annotate and show-version
make sense?
> 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-<foo>-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.
> Something similar can be done for incoming changes.
Indeed.
Stefan
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: VC command for showing outgoing changes
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
1 sibling, 2 replies; 14+ messages in thread
From: Dan Nicolaescu @ 2009-10-13 21:15 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Stefan Monnier <monnier@IRO.UMontreal.CA> 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.
You mean as a precondition of doing vc-outgoing?
I'd like to avoid tangling the two. vc-outgoing should be easy, and similar to
what we already do for `print-log', I am not so sure about `push'.
I think vc-outgoing can be useful even without a push operation, just
for showing the log and examining diffs.
> > vc-outgoing cannot quite use that because most commands that are defined
> > for log-view-mode do not make sense (annotate, next/previous file, show
> > version).
>
> The next/previous file seem to make just as much (or as little) sense
> for this as for log-view. Also, why don't annotate and show-version
> make sense?
These are tree level operations, annotate and show-version work on
files. (Especially annotate, it's code really really wants a file)
And yes, show-version and annotate do not really make much sense for
anything that is not a single file log (directory logs, or multiple file
logs).
> > 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-<foo>-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.
I am not so sure there's a need for multiple inheritance, backends could
create vc-<foo>-log-view-mode and vc-<foo>-outgoing-mode derived from
log-view-mode and log-view-outgoing-mode, respectively.
It might not be too complicated to try to (at least partially) implement
both your and my proposals and see which ones looks cleaner.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: VC command for showing outgoing changes
2009-10-13 21:15 ` Dan Nicolaescu
@ 2009-10-13 21:24 ` Giorgos Keramidas
2009-10-14 2:10 ` Stefan Monnier
1 sibling, 0 replies; 14+ messages in thread
From: Giorgos Keramidas @ 2009-10-13 21:24 UTC (permalink / raw)
To: Dan Nicolaescu; +Cc: Stefan Monnier, emacs-devel
On Tue, 13 Oct 2009 14:15:31 -0700 (PDT), Dan Nicolaescu <dann@ics.uci.edu> wrote:
> Stefan Monnier <monnier@IRO.UMontreal.CA> 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.
>
> You mean as a precondition of doing vc-outgoing?
> I'd like to avoid tangling the two. vc-outgoing should be easy, and similar to
> what we already do for `print-log', I am not so sure about `push'.
> I think vc-outgoing can be useful even without a push operation, just
> for showing the log and examining diffs.
Yes, it will be useful even without a `push' backend command. What
would also be nice is to be able to use log-view mode _with_ the
vc-outgoing command. For example mark a changeset with `m' in log-view
mode and see all the outgoing changes up to *that* changeset.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: VC command for showing outgoing changes
2009-10-13 21:15 ` Dan Nicolaescu
2009-10-13 21:24 ` Giorgos Keramidas
@ 2009-10-14 2:10 ` Stefan Monnier
1 sibling, 0 replies; 14+ messages in thread
From: Stefan Monnier @ 2009-10-14 2:10 UTC (permalink / raw)
To: Dan Nicolaescu; +Cc: emacs-devel
> You mean as a precondition of doing vc-outgoing?
> I'd like to avoid tangling the two. vc-outgoing should be easy, and
> similar to what we already do for `print-log', I am not so sure about
> `push'. I think vc-outgoing can be useful even without a push
> operation, just for showing the log and examining diffs.
I agree that outgoing is not useless even without push, but push is
more important: some of the `push' users use `outgoing', but all the
`outgoing' users use `push'. Or close enough.
> These are tree level operations, annotate and show-version work on
> files. (Especially annotate, it's code really really wants a file)
> And yes, show-version and annotate do not really make much sense for
> anything that is not a single file log (directory logs, or multiple file
> logs).
Actually, they do make sense, except you have to specify the file on
which you want to operate (presumably one of the files affected by the
current revision at point). In any case the point is that there's no
reason to treat those commands differently in log-view-mode and in
outgoing-mode.
I'm intetrested in figuring out what should be the differences between
those two modes, the fewer the merrier.
> I am not so sure there's a need for multiple inheritance, backends could
> create vc-<foo>-log-view-mode and vc-<foo>-outgoing-mode derived from
> log-view-mode and log-view-outgoing-mode, respectively.
Most vc-<foo>-log-view-mode basically setup regexps to recognize the
format used by the backend. Presumably vc-<foo>-outgoing-mode would
have to setup exactly the same regexps, which is rather unsatisfactory.
You could avoid this duplication if we had multiple inheritance.
Stefan
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: VC command for showing outgoing changes
2009-10-13 20:52 ` Stefan Monnier
2009-10-13 21:15 ` Dan Nicolaescu
@ 2009-12-05 19:45 ` Dan Nicolaescu
2009-12-05 19:52 ` Dan Nicolaescu
1 sibling, 1 reply; 14+ messages in thread
From: Dan Nicolaescu @ 2009-12-05 19:45 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Stefan Monnier <monnier@IRO.UMontreal.CA> 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-<foo>-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?
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: VC command for showing outgoing changes
2009-12-05 19:45 ` Dan Nicolaescu
@ 2009-12-05 19:52 ` Dan Nicolaescu
2009-12-05 20:53 ` Stefan Monnier
0 siblings, 1 reply; 14+ messages in thread
From: Dan Nicolaescu @ 2009-12-05 19:52 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Dan Nicolaescu <dann@ics.uci.edu> writes:
> Stefan Monnier <monnier@IRO.UMontreal.CA> 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-<foo>-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))
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: VC command for showing outgoing changes
2009-12-05 19:52 ` Dan Nicolaescu
@ 2009-12-05 20:53 ` Stefan Monnier
2009-12-05 21:35 ` Stefan Monnier
` (2 more replies)
0 siblings, 3 replies; 14+ messages in thread
From: Stefan Monnier @ 2009-12-05 20:53 UTC (permalink / raw)
To: Dan Nicolaescu; +Cc: emacs-devel
>> 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).
I'd call them vc-log-incoming and vc-log-outgoing, to make it clear that
it shows this info in the form of a changelog (we could also have
vc-diff-incoming, vc-diff-outgoing, for example).
[ Another option might be to specify the `outgoing' or `incoming' as
arguments to vc-print-log or vc-diff. Basically your `vc-(in|out)going'
is like (vc-print-log from-upstream to working-revision). ]
>> OK to check in?
Not quite, see below.
> + (when (boundp 'vc-log-view-type)
> + (set (make-local-variable 'log-view-type) vc-log-view-type))
Yuck. Please avoid dynamic scoping when possible. E.g. you could do it
simply via:
> +(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-call-backend ',backend 'log-view-mode)
(set (make-local-variable 'log-view-type) 'incoming)
> + (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)))))
The redundancy between these two functions is bad. Worse: there's
redundancy between this duplicate code and vc-print-log-internal as
well, some of what is different is a bug:
(vc-call-backend ',backend 'log-view-mode) should be called before
`vc-exec-after', as seen in vc-print-log-internal.
Also incoming/outgoing will probably want to obey vc-log-short-style, so
we really want to use as much of vc-print-log-internal as possible here.
> -(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]+\\)\\) +\\(.*\\)$"
Ah, so that's why you use dynamic-scoping for log-view-type, so it's
available while setting up the major-mode.
Hmm...
And there's another related problem:
> + (if (memq log-view-type '(short outgoing))
This is becoming very ad-hoc. I think the right answer is to let the
print-log backend operation set something up that the log-view-mode
operation can use subsequently. I.e. remove `log-view-mode' from the
generic part of the code, and let the backend set some permanent-local
variable in `print-log' to tell the subsequent `log-view-mode' which
kind of log to expect.
We could still define a generic `log-view-type' or `log-view-format'
variable for it, tho. The idea is that the generic part of the code may
want to use it, e.g. to display it in the mode-line (and let button-2
run a command that changes the format to something else). But it should
be set by the backend's `print-log' operation rather than by the
generic code.
WDYT?
Stefan
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: VC command for showing outgoing changes
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
2 siblings, 0 replies; 14+ messages in thread
From: Stefan Monnier @ 2009-12-05 21:35 UTC (permalink / raw)
To: Dan Nicolaescu; +Cc: emacs-devel
> This is becoming very ad-hoc. I think the right answer is to let the
> print-log backend operation set something up that the log-view-mode
> operation can use subsequently. I.e. remove `log-view-mode' from the
^^^^^^^^^^^^^
log-view-type
> generic part of the code, and let the backend set some permanent-local
> variable in `print-log' to tell the subsequent `log-view-mode' which
> kind of log to expect.
Stefan
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: VC command for showing outgoing changes
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
2 siblings, 0 replies; 14+ messages in thread
From: Dan Nicolaescu @ 2009-12-06 3:28 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> >> 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).
>
> I'd call them vc-log-incoming and vc-log-outgoing, to make it clear that
> it shows this info in the form of a changelog (we could also have
> vc-diff-incoming, vc-diff-outgoing, for example).
OK.
> [ Another option might be to specify the `outgoing' or `incoming' as
> arguments to vc-print-log or vc-diff. Basically your `vc-(in|out)going'
> is like (vc-print-log from-upstream to working-revision). ]
That's
> > +(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)))))
>
> The redundancy between these two functions is bad. Worse: there's
It's mostly an effect of how this was done: I just did outgoing, and
before sending this email copied + replaced outgoing->incoming as it was
the quickest way to get it done.
> redundancy between this duplicate code and vc-print-log-internal as
> well, some of what is different is a bug:
> (vc-call-backend ',backend 'log-view-mode) should be called before
> `vc-exec-after', as seen in vc-print-log-internal.
That change came after I wrote vc-outgoing-internal...
> Also incoming/outgoing will probably want to obey vc-log-short-style, so
> we really want to use as much of vc-print-log-internal as possible here.
It won't work: outgoing/incoming are project wide, so the directory vs
file logic used for vc-log-short-style does not apply.
> > -(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]+\\)\\) +\\(.*\\)$"
> j
> Ah, so that's why you use dynamic-scoping for log-view-type, so it's
> available while setting up the major-mode.
>
> Hmm...
Exactly it's ugly, but...
> And there's another related problem:
>
> > + (if (memq log-view-type '(short outgoing))
>
> This is becoming very ad-hoc. I think the right answer is to let the
> print-log backend operation set something up that the log-view-mode
> operation can use subsequently. I.e. remove `log-view-mode' from the
> generic part of the code, and let the backend set some permanent-local
> variable in `print-log' to tell the subsequent `log-view-mode' which
> kind of log to expect.
>
> We could still define a generic `log-view-type' or `log-view-format'
> variable for it, tho. The idea is that the generic part of the code may
> want to use it, e.g. to display it in the mode-line (and let button-2
> run a command that changes the format to something else). But it should
> be set by the backend's `print-log' operation rather than by the
> generic code.
>
> WDYT?
>
>
> Stefan
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: VC command for showing outgoing changes
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
2 siblings, 1 reply; 14+ messages in thread
From: Dan Nicolaescu @ 2009-12-06 8:33 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> >> 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).
>
> I'd call them vc-log-incoming and vc-log-outgoing, to make it clear that
> it shows this info in the form of a changelog (we could also have
> vc-diff-incoming, vc-diff-outgoing, for example).
OK.
> [ Another option might be to specify the `outgoing' or `incoming' as
> arguments to vc-print-log or vc-diff. Basically your `vc-(in|out)going'
> is like (vc-print-log from-upstream to working-revision). ]
That looks like it would make vc-print-log more complex and would make
this feature harder to find.
How about key bindings?
> > +(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)))))
>
> The redundancy between these two functions is bad. Worse: there's
It's mostly an effect of how this was done: I just did outgoing, and
before sending this email copied + replaced outgoing->incoming as it was
the quickest way to get it done.
> redundancy between this duplicate code and vc-print-log-internal as
> well, some of what is different is a bug:
> (vc-call-backend ',backend 'log-view-mode) should be called before
> `vc-exec-after', as seen in vc-print-log-internal.
That change came after I wrote vc-outgoing-internal...
> Also incoming/outgoing will probably want to obey vc-log-short-style, so
> we really want to use as much of vc-print-log-internal as possible here.
It won't work: outgoing/incoming are project wide, so the directory vs
file logic used for vc-log-short-style does not apply.
> > -(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]+\\)\\) +\\(.*\\)$"
> j
> Ah, so that's why you use dynamic-scoping for log-view-type, so it's
> available while setting up the major-mode.
>
> Hmm...
Exactly it's ugly, and it was already used by the short log mechanism.
> And there's another related problem:
>
> > + (if (memq log-view-type '(short outgoing))
This part is gone now, I let git use the default (i.e. long) log format.
> This is becoming very ad-hoc. I think the right answer is to let the
> print-log backend operation set something up that the log-view-mode
> operation can use subsequently. I.e. remove `log-view-mode' from the
> generic part of the code, and let the backend set some permanent-local
> variable in `print-log' to tell the subsequent `log-view-mode' which
> kind of log to expect.
Now there's a permanent-local variable `log-view-type', the values used
for it are 'long 'short 'log-outgoing 'log-incoming. Currently only
'short is used in any logic.
It would be nice if log-view-mode had an optional parameter to pass
this info. But maybe adding optional arguments to major modes is a big no-no.
> We could still define a generic `log-view-type' or `log-view-format'
> variable for it, tho. The idea is that the generic part of the code may
> want to use it, e.g. to display it in the mode-line (and let button-2
> run a command that changes the format to something else). But it should
> be set by the backend's `print-log' operation rather than by the
> generic code.
Why should the backend set this? It looks more cumbersome if all
backends had to take care of doing it.
Here's an updated patch.
OK?
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 6 Dec 2009 08:03:22 -0000
@@ -238,6 +238,11 @@ 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.")
+(put 'log-view-type 'permanent-local t)
+
+
;;;;
;;;; Actual code
;;;;
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 6 Dec 2009 08:03:24 -0000
@@ -341,6 +341,16 @@
;; backend does not support limiting the number of entries to show
;; it should return `limit-unsupported'.
;;
+;; * 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
@@ -1878,6 +1891,8 @@ Not all VC backends support short logs!"
(memq 'directory vc-log-short-style)
(memq 'file vc-log-short-style)))))
+ (with-current-buffer (get-buffer-create "*vc-change-log*")
+ (set (make-local-variable '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))
(pop-to-buffer "*vc-change-log*")
@@ -1913,6 +1928,22 @@ Not all VC backends support short logs!"
(setq vc-sentinel-movepoint (point))
(set-buffer-modified-p nil)))))
+(defun vc-incoming-outgoing-internal (backend remote-location buffer-name type)
+ (with-current-buffer (get-buffer-create buffer-name)
+ (set (make-local-variable 'log-view-type) type))
+ (vc-call-backend backend type buffer-name remote-location)
+ (pop-to-buffer buffer-name)
+ (let ((inhibit-read-only t))
+ (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))
+ (vc-exec-after
+ `(let ((inhibit-read-only t))
+ (shrink-window-if-larger-than-buffer)
+ (goto-char (point-min))
+ (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 +1996,32 @@ If WORKING-REVISION is non-nil, leave th
(vc-print-log-internal backend (list rootdir) working-revision 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
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 6 Dec 2009 08:03:24 -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-log-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-log-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 6 Dec 2009 08:03:25 -0000
@@ -560,25 +560,30 @@ If nil, use the value of `vc-diff-switch
"--pretty" "HEAD" "--")))
(when limit 'limit-unsupported))))
+(defun vc-git-log-outgoing (buffer remote-location)
+ (interactive)
+ (vc-git-command
+ buffer 0 nil
+ "log" (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)
(defvar log-view-per-file-logs)
-;; Dynamically bound.
-(defvar vc-short-log)
-
(define-derived-mode vc-git-log-view-mode log-view-mode "Git-Log-View"
(require 'add-log) ;; we need the faces add-log
;; Don't have file markers, so use impossible regexp.
(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-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 6 Dec 2009 08:03:26 -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-log-incoming (buffer remote-location)
+ (apply 'vc-bzr-command "missing" buffer 'async nil
+ (list "--theirs-only" (unless (string= remote-location "") remote-location))))
+
+(defun vc-bzr-log-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))
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: VC command for showing outgoing changes
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
0 siblings, 2 replies; 14+ messages in thread
From: Stefan Monnier @ 2009-12-07 1:40 UTC (permalink / raw)
To: Dan Nicolaescu; +Cc: emacs-devel
>> [ Another option might be to specify the `outgoing' or `incoming' as
>> arguments to vc-print-log or vc-diff. Basically your `vc-(in|out)going'
>> is like (vc-print-log from-upstream to working-revision). ]
> That looks like it would make vc-print-log more complex
Actually I really meant vc-print-log-internal and I don't think it would
make it any more complex (it might even stay almost unchanged).
The affected code would be the `print-log' operations in the backends.
But I don't know enough about how the various backends should/could
support incoming/outgoing to know whether it should be folded into the
`print-log' operation, or have its own backend operation(s).
We can keep them separate for now as your patch did. We can always add
default implementations which redirect those to the `print-log'
backend operation.
> and would make this feature harder to find.
That wouldn't preclude new vc-log-incoming and vc-log-outgoing front ends.
> How about key bindings?
No opinions here, except that they should preferably be related to
"log" somehow.
>> Also incoming/outgoing will probably want to obey vc-log-short-style, so
>> we really want to use as much of vc-print-log-internal as possible here.
> It won't work: outgoing/incoming are project wide, so the directory vs
> file logic used for vc-log-short-style does not apply.
I don't see why it wouldn't work: what you're saying is that it will
always follow the `directory' part of that logic. It's OK.
Note that there is no fundamental reason why `incoming' and `outgoing'
should always apply to the whole tree (tho there might be such
a limitation in all current implementations of the backends, but that's
another question altogether).
> Now there's a permanent-local variable `log-view-type', the values
> used for it are 'long 'short 'log-outgoing 'log-incoming.
> Currently only 'short is used in any logic.
Thanks. Really what this var does is specify the format used, and it
will mostly be used in a backend-specific way (after all, you almost
always need to know the backend in order to understand the format
anyway), so there is no strong need to standardize on particular values.
> It would be nice if log-view-mode had an optional parameter to pass
> this info. But maybe adding optional arguments to major modes is
> a big no-no.
For one, it's a big no-no, indeed. But also, log-view-type really
describes the buffer's content, so it makes a lot of sense for it to be
permanent-local.
Actually, for that same reason, we may prefer to name it vc-log-type.
Look at it this way: it's called "log-view-type", is declared in
log-view.el, and yet log-view.el doesn't make any use of it: Not good.
>> We could still define a generic `log-view-type' or `log-view-format'
>> variable for it, tho. The idea is that the generic part of the code may
>> want to use it, e.g. to display it in the mode-line (and let button-2
>> run a command that changes the format to something else). But it should
>> be set by the backend's `print-log' operation rather than by the
>> generic code.
> Why should the backend set this?
Because it's (currently) only ever used in the backend's log-view-mode,
i.e. it's really an internal issue of the backend. Many backends don't
have that much choice, other backends allow more choices of formats,
also some backends may prefer to use a vc-log-message-re that simply
matches all relevant formats, thu not needing log-view-type at all.
> It looks more cumbersome if all backends had to take care of doing it.
Not all of them would need it. And it would make it easier to extend
the set of formats for specific backends.
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.
Stefan
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: VC command for showing outgoing changes
2009-12-07 1:40 ` Stefan Monnier
@ 2009-12-07 9:06 ` Dan Nicolaescu
2010-01-01 18:56 ` Dan Nicolaescu
1 sibling, 0 replies; 14+ messages in thread
From: Dan Nicolaescu @ 2009-12-07 9:06 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
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.
Can that be done in a subsequent change? We are only talking about 15
duplicate lines here.
I'd rather not miss the feature freeze, and I am not sure I have to make
the change before that.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: VC command for showing outgoing changes
2009-12-07 1:40 ` Stefan Monnier
2009-12-07 9:06 ` Dan Nicolaescu
@ 2010-01-01 18:56 ` Dan Nicolaescu
1 sibling, 0 replies; 14+ messages in thread
From: Dan Nicolaescu @ 2010-01-01 18:56 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
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
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2010-01-01 18:56 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).