[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bug#881: patch for bug #881
From: |
Stefan Monnier |
Subject: |
Re: bug#881: patch for bug #881 |
Date: |
Thu, 07 Jan 2010 15:07:39 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1.91 (gnu/linux) |
> Here's a 100% untested version of this. It serves all the needs I can
> think off at the moment.
> git can add "--amend" and "--signoff" to `log-edit-extra-flags'.
> Author: "foo bar" address@hidden
> can be dealt with using `log-edit-before-checkin-process'.
> We can add a key binding to log-edit.el to insert Author: in the buffer.
> The part that removes the extra markup (i.e. Author: ) from the buffer
> is not implemented, but it should not be too hard.
> What do you think?
I dislike the `log-edit-mode' which returns a function rather that
running the code directly. And of course the "FIXME: this should be
a function in log-edit.el" would need to be fixed.
This said, I was thinking of something simpler: let the RFC822-like
message go unchanged to the backend, so if the backend doesn't support
"Author:" that line will just end up staying in the commit message,
which doesn't seem like a bad way to handle this case.
Of course, vc.el should provide some generic function(s) to parse the
RFC822-like format, so backends don't have to do it all by hand.
Stefan
> Index: vc.el
> ===================================================================
> RCS file: /cvsroot/emacs/emacs/lisp/vc.el,v
> retrieving revision 1.746
> diff -u -3 -p -r1.746 vc.el
> --- vc.el 7 Dec 2009 09:02:16 -0000 1.746
> +++ vc.el 7 Jan 2010 16:56:25 -0000
> @@ -261,7 +261,7 @@
> ;; Unregister FILE from this backend. This is only needed if this
> ;; backend may be used as a "more local" backend for temporary editing.
> ;;
> -;; * checkin (files rev comment)
> +;; * checkin (files rev comment &rest args)
> ;;
> ;; Commit changes in FILES to this backend. If REV is non-nil, that
> ;; should become the new revision number (not all backends do
> @@ -269,6 +269,7 @@
> ;; implementation should pass the value of vc-checkin-switches to
> ;; the backend command. (Note: in older versions of VC, this
> ;; command took a single file argument and not a list.)
> +;; ARGS should be passed to the backend command.
> ;;
> ;; * find-revision (file rev buffer)
> ;;
> @@ -477,6 +478,12 @@
> ;; Return the revision number that follows REV for FILE, or nil if no such
> ;; revision exists.
> ;;
> +;; - log-edit-mode ()
> +;;
> +;; Return a symbol that is the mode to use for editing the check in
> +;; log. This defaults to `log-edit-mode' and is expected to be
> +;; changed (if at all) to a derived mode of `log-edit-mode'.
> +;;
> ;; - check-headers ()
> ;;
> ;; Return non-nil if the current buffer contains any version headers.
> @@ -1348,7 +1365,7 @@ Runs the normal hooks `vc-before-checkin
> files rev comment initial-contents
> "Enter a change comment."
> "*VC-log*"
> - (lambda (files rev comment)
> + (lambda (files rev comment extra-flags)
> (message "Checking in %s..." (vc-delistify files))
> ;; "This log message intentionally left almost blank".
> ;; RCS 5.7 gripes about white-space-only comments too.
> @@ -1359,7 +1376,7 @@ Runs the normal hooks `vc-before-checkin
> ;; We used to change buffers to get local value of
> vc-checkin-switches,
> ;; but 'the' local buffer is not a well-defined concept for filesets.
> (progn
> - (vc-call-backend backend 'checkin files rev comment)
> + (vc-call-backend backend 'checkin files rev comment extra-flags)
> (mapc 'vc-delete-automatic-version-backups files))
> `((vc-state . up-to-date)
> (vc-checkout-time . ,(nth 5 (file-attributes file)))
> @@ -1729,7 +1746,7 @@ The headers are reset to their non-expan
> files rev oldcomment t
> "Enter a replacement change comment."
> "*VC-log*"
> - (lambda (files rev comment)
> + (lambda (files rev comment ignored)
> (vc-call-backend
> ;; Less of a kluge than it looks like; log-view mode only passes
> ;; this function a singleton list. Arguments left in this form in
> @@ -2414,6 +2431,8 @@ to provide the `find-revision' operation
> (defalias 'vc-default-check-headers 'ignore)
> +(defun vc-default-log-edit-mode (backend) 'log-edit-mode)
> +
> (defun vc-default-log-view-mode (backend) (log-view-mode))
> (defun vc-default-show-log-entry (backend rev)
> Index: vc-dispatcher.el
> ===================================================================
> RCS file: /cvsroot/emacs/emacs/lisp/vc-dispatcher.el,v
> retrieving revision 1.71
> diff -u -3 -p -r1.71 vc-dispatcher.el
> --- vc-dispatcher.el 1 Oct 2009 03:32:27 -0000 1.71
> +++ vc-dispatcher.el 7 Jan 2010 16:56:26 -0000
> @@ -526,7 +526,9 @@ NOT-URGENT means it is ok to continue if
> (log-edit 'vc-finish-logentry
> nil
> `((log-edit-listfun . (lambda () ',fileset))
> - (log-edit-diff-function . (lambda () (vc-diff nil)))))
> + (log-edit-diff-function . (lambda () (vc-diff nil))))
> + nil
> + (vc-call-backend (car fileset) 'log-edit-mode))
> (set (make-local-variable 'vc-log-fileset) fileset)
> (make-local-variable 'vc-log-extra)
> (set-buffer-modified-p nil)
> @@ -587,6 +589,15 @@ the buffer contents as a comment."
> (or (vc-dispatcher-browsing) (vc-buffer-sync)))
> (unless vc-log-operation
> (error "No log operation is pending"))
> +
> + ;; FIXME: this should be a function in log-edit.el
> + (when log-edit-before-checkin-process
> + (dolist (crt log-edit-before-checkin-process)
> + ;; Remove all lines matching (car crt)
> + ;; Append to `log-edit-extra-flags' the results of (cdr crt).
> + )
> + )
> +
> ;; save the parameters held in buffer-local variables
> (let ((logbuf (current-buffer))
> (log-operation vc-log-operation)
> @@ -601,7 +612,8 @@ the buffer contents as a comment."
> (funcall log-operation
> log-fileset
> log-extra
> - log-entry))
> + log-entry
> + log-edit-extra-flags))
> ;; Remove checkin window (after the checkin so that if that fails
> ;; we don't zap the log buffer and the typing therein).
> ;; -- IMO this should be replaced with quit-window
> Index: log-edit.el
> ===================================================================
> RCS file: /cvsroot/emacs/emacs/lisp/log-edit.el,v
> retrieving revision 1.56
> diff -u -3 -p -r1.56 log-edit.el
> --- log-edit.el 2 Oct 2009 03:48:41 -0000 1.56
> +++ log-edit.el 7 Jan 2010 16:56:26 -0000
> @@ -185,6 +185,25 @@ when this variable is set to nil.")
> (defvar log-edit-callback nil)
> (defvar log-edit-diff-function nil)
> (defvar log-edit-listfun nil)
> +(defvar log-edit-extra-flags nil
> + "List of extra flags to pass to the check in command.")
> +(defvar log-edit-before-checkin-process nil
> + "Alist that contains instructions for processing the commit message before
> check in.
> +
> +The format is: (REGEXP . INSTRUCTIONS).
> +
> +All lines matching REGEXP are removed.
> +
> +For example:
> +
> +(\"^#.*\" . nil)
> +means: just remove all lines starting with #. This can be used
> +to insert lines in the commit buffer that contain for example the
> +list of files to be committed.
> +
> +(\"Author: \\(.*\\)\" . (list \"--author\" (match-string 1)))
> +means: append (list \"--author\" (match-string 1)) to
> +`log-edit-extra-flags'.")
> (defvar log-edit-parent-buffer nil)
> ;;; Originally taken from VC-Log mode
> @@ -315,9 +334,10 @@ automatically."
> (2 font-lock-function-name-face))))
> ;;;###autoload
> -(defun log-edit (callback &optional setup params buffer &rest ignore)
> +(defun log-edit (callback &optional setup params buffer mode &rest ignore)
> "Setup a buffer to enter a log message.
> -\\<log-edit-mode-map>The buffer will be put in `log-edit-mode'.
> +\\<log-edit-mode-map>The buffer will be put in mode MODE or `log-edit-mode'
> +if MODE is nil.
> If SETUP is non-nil, the buffer is then erased and `log-edit-hook' is run.
> Mark and point will be set around the entire contents of the buffer so
> that it is easy to kill the contents of the buffer with \\[kill-region].
> @@ -338,7 +358,9 @@ uses the current buffer."
> (when (and log-edit-setup-invert (not (eq setup 'force)))
> (setq setup (not setup)))
> (when setup (erase-buffer))
> - (log-edit-mode)
> + (if mode
> + (funcall mode)
> + (log-edit-mode))
> (set (make-local-variable 'log-edit-callback) callback)
> (if (listp params)
> (dolist (crt params)
- Re: bug#881: patch for bug #881, (continued)
- Re: bug#881: patch for bug #881, Eli Zaretskii, 2010/01/05
- Re: bug#881: patch for bug #881, Stefan Monnier, 2010/01/05
- Re: bug#881: patch for bug #881, Dan Nicolaescu, 2010/01/06
- Re: bug#881: patch for bug #881, Stefan Monnier, 2010/01/06
- Re: bug#881: patch for bug #881, Dan Nicolaescu, 2010/01/06
- Re: bug#881: patch for bug #881, Stefan Monnier, 2010/01/06
- Re: bug#881: patch for bug #881, Dan Nicolaescu, 2010/01/07
- Re: bug#881: patch for bug #881,
Stefan Monnier <=
- Re: bug#881: patch for bug #881, Eli Zaretskii, 2010/01/06
- Re: bug#881: patch for bug #881, Óscar Fuentes, 2010/01/06
- Re: bug#881: patch for bug #881, Stefan Monnier, 2010/01/06
- Re: bug#881: patch for bug #881, Eli Zaretskii, 2010/01/06
- Re: bug#881: patch for bug #881, Juanma Barranquero, 2010/01/07
- bzr --fixes [was Re: bug#881: patch for bug #881], Glenn Morris, 2010/01/07
- Re: bzr --fixes [was Re: bug#881: patch for bug #881], Juanma Barranquero, 2010/01/07
- Re: bzr --fixes, Glenn Morris, 2010/01/07
- Re: bzr --fixes, Juanma Barranquero, 2010/01/07
- Re: bzr --fixes, Eli Zaretskii, 2010/01/08