From: Eli Zaretskii <eliz@gnu.org>
To: rms@gnu.org
Cc: philipk@posteo.net, 57400@debbugs.gnu.org, rpluim@gmail.com,
ane@iki.fi, juri@linkov.net
Subject: bug#57400: 29.0.50; Support sending patches from VC directly
Date: Tue, 11 Oct 2022 08:37:26 +0300 [thread overview]
Message-ID: <83pmeygbu1.fsf@gnu.org> (raw)
In-Reply-To: <E1oi0pt-0000Rx-Uo@fencepost.gnu.org> (message from Richard Stallman on Mon, 10 Oct 2022 18:01:21 -0400)
> Cc: philipk@posteo.net, 57400@debbugs.gnu.org, rpluim@gmail.com, ane@iki.fi
> From: Richard Stallman <rms@gnu.org>
> Date: Mon, 10 Oct 2022 18:01:21 -0400
>
> Can someone please send me a self-contained description of this new
> feature?
It's in Git, including documentation which describes the feature. You
can find the changeset by searching "git log" output for the bug
number, 57400. I attach below the docs parts of the changeset and the
command itself.
> Which VC backends does it support?
All of them, AFAIU.
diff --git a/doc/emacs/vc1-xtra.texi b/doc/emacs/vc1-xtra.texi
index 05d2144..66d3f51 100644
--- a/doc/emacs/vc1-xtra.texi
+++ b/doc/emacs/vc1-xtra.texi
@@ -16,6 +16,7 @@ Miscellaneous VC
* Revision Tags:: Symbolic names for revisions.
* Version Headers:: Inserting version control headers into working files.
* Editing VC Commands:: Editing the VC shell commands that Emacs will run.
+* Preparing Patches:: Preparing and Composing patches from within VC
@end menu
@node Change Logs and VC
@@ -282,6 +283,32 @@ Editing VC Commands
additional branches to the end of the @samp{git log} command that VC
is about to run.
+@node Preparing Patches
+@subsubsection Preparing Patches
+
+@findex vc-prepare-patch
+When collaborating on projects it is common to send patches via email,
+to share changes. If you wish to do this using VC, you can use the
+@code{vc-prepare-patch} command. This will prompt you for the
+revisions you wish to share, and which destination email address(es)
+to use. The command will then prepare those revisions using your
+@abbr{MUA, Mail User Agent} for you to review and send.
+
+@vindex vc-prepare-patches-separately
+Depending on the value of the user option
+@code{vc-prepare-patches-separately}, @code{vc-prepare-patch} will
+generate one or more messages. The default value @code{t} means
+prepare and display a message for each revision, one after another. A
+value of @code{nil} means to generate a single message with all
+patches attached in the body.
+
+@vindex vc-default-patch-addressee
+If you expect to contribute patches on a regular basis, you can set
+the user option @code{vc-default-patch-addressee} to the address(es)
+you wish to use. This will be used as the default value when invoking
+@code{vc-prepare-patch}. Project maintainers may consider setting
+this as a directory local variable (@pxref{Directory Variables}).
+
@node Customizing VC
@subsection Customizing VC
diff --git a/etc/NEWS b/etc/NEWS
index f674423..ca85705 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1866,6 +1866,24 @@ Git commands display summary lines. See the two new user options
It is used to style the line that separates the 'log-edit' headers
from the 'log-edit' summary.
+---
+*** The function 'vc-read-revision' accepts a new MULTIPLE argument.
+If non-nil, multiple revisions can be queried. This is done using
+'completing-read-multiple'.
+
+---
+*** New function 'vc-read-multiple-revisions'
+This function invokes 'vc-read-revision' with a non-nil value for
+MULTIPLE.
+
++++
+*** New command 'vc-prepare-patch'.
+Patches for any version control system can be prepared using VC. The
+command will query what commits to send and will compose messages for
+your mail user agent. The behaviour of 'vc-prepare-patch' can be
+modified by the user options 'vc-prepare-patches-separately' and
+'vc-default-patch-addressee'.
+
** Message
---
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 787dd51..72189cf 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -574,6 +574,16 @@
;; containing FILE-OR-DIR. The optional REMOTE-NAME specifies the
;; remote (in Git parlance) whose URL is to be returned. It has
;; only a meaning for distributed VCS and is ignored otherwise.
+;;
+;; - prepare-patch (rev)
+;;
+;; Prepare a patch and return a property list with the keys
+;; `:subject' indicating the patch message as a string, `:buffer'
+;; with a buffer object that contains the entire patch message and
+;; `:body-start' and `:body-end' demarcating what part of said
+;; buffer should be inserted into an inline patch. If the two last
+;; properties are omitted, `point-min' and `point-max' will
+;; respectively be used instead.
+(defcustom vc-prepare-patches-separately t
+ "Non-nil means that `vc-prepare-patch' creates a single message.
+A single message is created by attaching all patches to the body
+of a single message. If nil, each patch will be sent out in a
+separate message, which will be prepared sequentially."
+ :type 'boolean
+ :safe #'booleanp
+ :version "29.1")
+
+(defcustom vc-default-patch-addressee nil
+ "Default addressee for `vc-prepare-patch'.
+If nil, no default will be used. This option may be set locally."
+ :type '(choice (const :tag "No default" nil)
+ (string :tag "Addressee"))
+ :safe #'stringp
+ :version "29.1")
+
+;;;###autoload
+(defun vc-prepare-patch (addressee subject revisions)
+ "Compose an Email sending patches for REVISIONS to ADDRESSEE.
+If `vc-prepare-patches-separately' is non-nil, SUBJECT will be used
+as the default subject for the message. Otherwise a separate
+message will be composed for each revision.
+
+When invoked interactively in a Log View buffer with marked
+revisions, these revisions will be used."
+ (interactive
+ (let ((revs (or (log-view-get-marked)
+ (vc-read-multiple-revisions "Revisions: ")))
+ to)
+ (require 'message)
+ (while (null (setq to (completing-read-multiple
+ (format-prompt
+ "Addressee"
+ vc-default-patch-addressee)
+ (message--name-table "")
+ nil nil nil nil
+ vc-default-patch-addressee)))
+ (message "At least one addressee required.")
+ (sit-for blink-matching-delay))
+ (list (string-join to ", ")
+ (and (not vc-prepare-patches-separately)
+ (read-string "Subject: " "[PATCH] " nil nil t))
+ revs)))
+ (save-current-buffer
+ (vc-ensure-vc-buffer)
+ (let ((patches (mapcar (lambda (rev)
+ (vc-call-backend
+ (vc-responsible-backend default-directory)
+ 'prepare-patch rev))
+ revisions)))
+ (if vc-prepare-patches-separately
+ (dolist (patch patches)
+ (compose-mail addressee
+ (plist-get patch :subject)
+ nil nil nil nil
+ `((kill-buffer ,(plist-get patch :buffer))
+ (exit-recursive-edit)))
+ (rfc822-goto-eoh) (forward-line)
+ (save-excursion ;don't jump to the end
+ (insert-buffer-substring
+ (plist-get patch :buffer)
+ (plist-get patch :body-start)
+ (plist-get patch :body-end)))
+ (recursive-edit))
+ (compose-mail addressee subject nil nil nil nil
+ (mapcar
+ (lambda (p)
+ (list #'kill-buffer (plist-get p :buffer)))
+ patches))
+ (rfc822-goto-eoh)
+ (forward-line)
+ (save-excursion
+ (dolist (patch patches)
+ (mml-attach-buffer (buffer-name (plist-get patch :buffer))
+ "text/x-patch"
+ (plist-get patch :subject)
+ "attachment")))
+ (open-line 2)))))
+
(defun vc-default-responsible-p (_backend _file)
"Indicate whether BACKEND is responsible for FILE.
The default is to return nil always."
next prev parent reply other threads:[~2022-10-11 5:37 UTC|newest]
Thread overview: 117+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-25 8:47 bug#57400: 29.0.50; Support sending patches from VC directly Antoine Kalmbach
2022-08-26 7:37 ` Philip Kaludercic
2022-08-26 10:15 ` Antoine Kalmbach
2022-08-26 10:35 ` Philip Kaludercic
2022-08-26 10:45 ` Antoine Kalmbach
2022-08-26 10:58 ` Eli Zaretskii
2022-08-26 11:26 ` Philip Kaludercic
2022-08-26 11:44 ` Eli Zaretskii
2022-08-26 12:05 ` Philip Kaludercic
2022-08-26 12:26 ` Eli Zaretskii
2022-08-26 13:10 ` Antoine Kalmbach
2022-08-26 13:17 ` Eli Zaretskii
2022-08-26 13:29 ` Philip Kaludercic
2022-08-26 14:21 ` Eli Zaretskii
2022-08-27 8:21 ` Philip Kaludercic
2022-08-27 9:21 ` Eli Zaretskii
2022-08-27 9:30 ` Philip Kaludercic
2022-08-26 12:08 ` Antoine Kalmbach
2022-08-26 12:28 ` Eli Zaretskii
2022-08-28 4:07 ` Richard Stallman
2022-10-03 18:59 ` Philip Kaludercic
2022-10-03 19:06 ` Lars Ingebrigtsen
2022-10-03 19:23 ` Eli Zaretskii
2022-10-04 19:19 ` Philip Kaludercic
2022-10-04 19:33 ` Eli Zaretskii
2022-10-03 21:22 ` Philip Kaludercic
2022-10-03 21:55 ` Philip Kaludercic
2022-10-03 23:32 ` Lars Ingebrigtsen
2022-10-04 6:46 ` Eli Zaretskii
2022-10-04 6:41 ` Eli Zaretskii
2022-10-04 7:10 ` Philip Kaludercic
2022-10-04 8:00 ` Eli Zaretskii
2022-10-04 10:40 ` Philip Kaludercic
2022-10-04 10:42 ` Philip Kaludercic
2022-10-04 12:25 ` Eli Zaretskii
2022-10-04 12:24 ` Eli Zaretskii
2022-10-04 18:08 ` Philip Kaludercic
2022-10-05 16:07 ` Antoine Kalmbach
2022-10-05 17:34 ` Philip Kaludercic
2022-10-05 17:48 ` Philip Kaludercic
2022-10-05 18:32 ` Lars Ingebrigtsen
2022-10-05 18:46 ` Philip Kaludercic
2022-10-05 19:08 ` Lars Ingebrigtsen
2022-10-06 8:21 ` Robert Pluim
2022-10-06 8:35 ` Philip Kaludercic
2022-10-06 8:59 ` Robert Pluim
2022-10-06 9:12 ` Philip Kaludercic
2022-10-06 11:02 ` Philip Kaludercic
2022-10-05 19:57 ` Juri Linkov
2022-10-06 12:03 ` Lars Ingebrigtsen
2022-10-07 22:48 ` Richard Stallman
2022-10-10 14:39 ` Filipp Gunbin
2022-10-10 18:58 ` Juri Linkov
2022-10-11 0:27 ` Lars Ingebrigtsen
2022-10-11 0:26 ` Lars Ingebrigtsen
2022-10-05 18:17 ` Eli Zaretskii
2022-10-05 18:45 ` Philip Kaludercic
2022-10-06 9:14 ` Philip Kaludercic
2022-10-06 9:19 ` Eli Zaretskii
2022-10-06 22:22 ` Dmitry Gutov
2022-10-07 6:36 ` Eli Zaretskii
2022-10-07 12:06 ` Dmitry Gutov
2022-10-06 11:33 ` Robert Pluim
2022-10-06 12:38 ` Philip Kaludercic
2022-10-06 12:58 ` Robert Pluim
2022-10-06 14:37 ` Philip Kaludercic
2022-10-06 14:43 ` Robert Pluim
2022-10-06 15:54 ` Eli Zaretskii
2022-10-06 16:27 ` Philip Kaludercic
2022-10-07 7:58 ` Juri Linkov
2022-10-07 11:42 ` Philip Kaludercic
2022-10-08 10:03 ` Philip Kaludercic
2022-10-08 19:34 ` Juri Linkov
2022-10-09 12:15 ` Philip Kaludercic
2022-10-10 19:03 ` Juri Linkov
2022-10-11 12:44 ` Philip Kaludercic
2022-10-11 13:58 ` Robert Pluim
2022-10-15 18:54 ` Juri Linkov
2022-10-16 9:40 ` Philip Kaludercic
2022-10-11 19:30 ` Philip Kaludercic
2022-10-11 19:47 ` Juri Linkov
2022-10-11 19:49 ` Philip Kaludercic
2022-10-12 22:01 ` Richard Stallman
2022-10-13 7:04 ` Juri Linkov
2022-10-13 21:12 ` Richard Stallman
2022-10-15 19:02 ` Juri Linkov
2022-10-13 8:55 ` Philip Kaludercic
2022-10-13 17:30 ` Juri Linkov
2022-10-13 19:44 ` Philip Kaludercic
2022-10-13 20:25 ` Philip Kaludercic
2022-10-13 20:33 ` Eli Zaretskii
2022-10-13 22:05 ` Philip Kaludercic
2022-10-14 6:50 ` Eli Zaretskii
2022-10-14 21:28 ` Richard Stallman
2022-10-14 21:47 ` Philip Kaludercic
2022-10-15 6:57 ` Eli Zaretskii
2022-10-15 11:44 ` Philip Kaludercic
2022-10-15 12:20 ` Eli Zaretskii
2022-10-15 15:15 ` Philip Kaludercic
2022-10-15 15:16 ` Eli Zaretskii
2022-10-15 15:24 ` Philip Kaludercic
2022-10-10 22:01 ` Richard Stallman
2022-10-11 5:37 ` Eli Zaretskii [this message]
2022-10-12 21:59 ` Richard Stallman
2022-10-06 22:10 ` Dmitry Gutov
2022-10-07 8:03 ` Philip Kaludercic
2022-10-07 12:56 ` Dmitry Gutov
2022-10-07 15:30 ` Philip Kaludercic
2022-10-07 15:47 ` Dmitry Gutov
2022-10-07 15:54 ` Philip Kaludercic
2022-10-08 22:34 ` Richard Stallman
2022-10-08 12:11 ` Philip Kaludercic
2022-10-08 12:44 ` German Pacenza
2022-10-08 13:02 ` Philip Kaludercic
2022-10-08 13:07 ` Dmitry Gutov
2022-10-08 13:42 ` Philip Kaludercic
2022-10-08 14:02 ` Dmitry Gutov
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83pmeygbu1.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=57400@debbugs.gnu.org \
--cc=ane@iki.fi \
--cc=juri@linkov.net \
--cc=philipk@posteo.net \
--cc=rms@gnu.org \
--cc=rpluim@gmail.com \
/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 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).