Skip to contentSkip to conversation

ez: allow sending all versions of a patch series in the same thread

PATCH Applied Philippe Blain 2 participants 9 messages Feb 22, 2023 – Feb 27, 2023

lore
Share & tools
lore
#0 lore raw

cover ez: allow sending all versions of a patch series in the same thread

Sending a new iteration of a series in the same thread as the previous one is the preferred workflow on some lists, the Git mailing list being an example [1].

This series allows that workflow in b4 by adding a '--same-thread' option to 'b4 send', with an associated config option.

Cheers,

Philippe.

[1] https://git-scm.com/docs/MyFirstContribution#v2-git-send-email

---
Philippe Blain (3):
ez: allow iterations to be sent in a single thread
ez: add '--same-thread' option to 'b4 send'
ez: add 'b4.send-same-thread' config for 'b4 send --same-thread'

 b4/command.py             |  2 ++
 b4/ez.py                  | 14 ++++++++++++--
 docs/config.rst           |  4 ++++
 docs/contributor/send.rst |  5 +++++
 4 files changed, 23 insertions(+), 2 deletions(-)

---
base-commit: a3281834d6d5dec44f58071fca2d22e04a97fe18
change-id: 20230219-send-iterations-in-same-thread-c50a3bc4ed9e --
b4

#1 lore raw

PATCH 1/3 ez: allow iterations to be sent in a single thread

Some projects prefer further iterations of a patch series to be sent in the same thread as previous ones. Usually this means that the cover letter of v2 is sent as a reply to the cover letter of v1, etc.

Add a new optional argument to get_prep_branch_as_patches, 'samethread', defaulting to False. When True, add an 'In-Reply-To' header to the first mail in the series, referencing the Message-ID of the previous iterations's cover letter.

This functionality will be exposed to users in a following commit.

---
 b4/ez.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
b4/ez.py +8 -1
index 74afddc..dac5e2a 100644
@@ -1117,7 +1117,8 @@ def get_mailfrom() -> Tuple[str, str]:
     return usercfg.get('name'), usercfg.get('email')
 
 
-def get_prep_branch_as_patches(movefrom: bool = True, thread: bool = True, addtracking: bool = True
+def get_prep_branch_as_patches(movefrom: bool = True, thread: bool = True, addtracking: bool = True,
+                               samethread: bool = False
                                ) -> Tuple[List, List, str, List[Tuple[str, email.message.Message]]]:
     cover, tracking = load_cover(strip_comments=True)
 
@@ -1191,6 +1192,12 @@ def get_prep_branch_as_patches(movefrom: bool = True, thread: bool = True, addtr
     if addtracking:
         patches[0][1].add_header('X-B4-Tracking', thdata)
 
+    if samethread and revision > 1:
+        oldrev = revision - 1
+        voldrev =  f'v{oldrev}'
+        oldmsgid =  tracking['series']['history'][voldrev][-1]
+        patches[0][1].add_header('In-Reply-To', f'<{oldmsgid}>')
+
     tag_msg = f'{csubject.full_subject}\n\n{cover_letter}'
     return alltos, allccs, tag_msg, patches
 
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/3 ez: add '--same-thread' option to 'b4 send'

In reply to Philippe Blain

The previous commit tweaked get_prep_branch_as_patches to optionnally send further iterations of a patch series in the same thread as previous ones.

Expose that functionality to the command line by adding a '--same-thread' option (defaulting to False) to 'b4 send', and pass it down to get_prep_branch_as_patches. Document the new feature.

---
 b4/command.py             | 2 ++
 b4/ez.py                  | 2 +-
 docs/contributor/send.rst | 5 +++++
 3 files changed, 8 insertions(+), 1 deletion(-)
b4/command.py +2 -0
index a7a5aa9..21f0d0d 100644
@@ -323,6 +323,8 @@ def setup_parser() -> argparse.ArgumentParser:
                          help='Resend a previously sent version of the series')
     sp_send.add_argument('--no-sign', action='store_true', default=False,
                          help='Do not add the cryptographic attestation signature header')
+    sp_send.add_argument('--same-thread', action='store_true', default=False,
+                         help='Keep all versions in the same thread')
     ag_sendh = sp_send.add_argument_group('Web submission', 'Authenticate with the web submission endpoint')
     ag_sendh.add_argument('--web-auth-new', dest='auth_new', action='store_true', default=False,
                           help='Initiate a new web authentication request')
b4/ez.py +1 -1
index dac5e2a..4013f29 100644
@@ -1295,7 +1295,7 @@ def cmd_send(cmdargs: argparse.Namespace) -> None:
             sys.exit(1)
 
         try:
-            todests, ccdests, tag_msg, patches = get_prep_branch_as_patches()
+            todests, ccdests, tag_msg, patches = get_prep_branch_as_patches(samethread=cmdargs.same_thread)
         except RuntimeError as ex:
             logger.critical('CRITICAL: Failed to convert range to patches: %s', ex)
             sys.exit(1)
docs/contributor/send.rst +5 -0
index bff67aa..6abceac 100644
@@ -233,6 +233,11 @@ Command line flags
 ``--not-me-too``
   Removes your own email address from the recipients.
 
+``--same-thread``
+  When sending a new version of a series, make it part of the same
+  thread as the previous one. The first mail will be sent as a reply
+  to the previous version's cover letter.
+
 ``--no-sign``
   Don't sign your patches with your configured attestation mechanism.
   Note, that patch signing is required for the web submission endpoint,
Signature · 1 line
2.34.1
#3 lore raw

PATCH 3/3 ez: add 'b4.send-same-thread' config for 'b4 send --same-thread'

In reply to Philippe Blain

Allow the default for the '--same-thread' option of 'b4 send' to be set in b4's config by adding a 'b4.send-same-thread' configuration option.

---
 b4/ez.py        | 5 ++++-
 docs/config.rst | 4 ++++
 2 files changed, 8 insertions(+), 1 deletion(-)
b4/ez.py +4 -1
index 4013f29..f0861ed 100644
@@ -1295,7 +1295,10 @@ def cmd_send(cmdargs: argparse.Namespace) -> None:
             sys.exit(1)
 
         try:
-            todests, ccdests, tag_msg, patches = get_prep_branch_as_patches(samethread=cmdargs.same_thread)
+            samethread = config.get('send-same-thread', '').lower() in {'yes', 'true', 'y'}
+            if cmdargs.same_thread or samethread:
+                samethread = True
+            todests, ccdests, tag_msg, patches = get_prep_branch_as_patches(samethread=samethread)
         except RuntimeError as ex:
             logger.critical('CRITICAL: Failed to convert range to patches: %s', ex)
             sys.exit(1)
docs/config.rst +4 -0
index b3ab5ca..0fd68c5 100644
@@ -351,6 +351,10 @@ Contributor-oriented settings
 
   Default:: ``scripts/get_maintainer.pl --nogit --nogit-fallback --nogit-chief-penguins --norolestats --nom``
 
+``b4.send-same-thread`` (v0.13+)
+  Send all versions of a patch series as part of the same thread.
+
+  Default: ``no``
 
 ``b4.prep-cover-strategy`` (v0.10+)
   Alternative cover letter storage strategy to use (see :ref:`prep_cover_strategies`).
Signature · 1 line
2.34.1
#4 lore raw
In reply to Philippe Blain
Quoted 6 lines · Philippe Blain

Sending a new iteration of a series in the same thread as the previous one is the preferred workflow on some lists, the Git mailing list being an example [1].

This series allows that workflow in b4 by adding a '--same-thread' option to 'b4 send', with an associated config option.

Thanks, Philippe.

I think I prefer to *just* have this be set in config, without the CLI switch. The goal is to make "b4 prep" workflow be friendly to newbies, so having --help output a ton of options is the situation I want to avoid.

I'll take this in if you drop the --same-thread switch.

Cheers,
-K

#5 lore raw

Hi Konstantin,

Le 2023-02-21 à 21:25, Konstantin Ryabitsev a écrit :

Quoted 8 lines · Philippe Blain
Quoted 6 lines

Sending a new iteration of a series in the same thread as the previous one is the preferred workflow on some lists, the Git mailing list being an example [1].

This series allows that workflow in b4 by adding a '--same-thread' option to 'b4 send', with an associated config option.

Quoted 7 lines

Thanks, Philippe.

I think I prefer to *just* have this be set in config, without the CLI switch. The goal is to make "b4 prep" workflow be friendly to newbies, so having --help output a ton of options is the situation I want to avoid.

I'll take this in if you drop the --same-thread switch.

Yeah, I agree this will usually be a "set it once for this project and forget" kind of thing, so it makes sense for it to be only settable in the config.

I will do that for v2.

Thanks,

Philippe.

#6 lore raw

PATCH v2 1/1 ez: allow sending all versions of a patch series in the same thread

In reply to Philippe Blain

Some projects prefer further iterations of a patch series to be sent in the same thread as previous ones. Usually this means that the cover letter of v2 is sent as a reply to the cover letter of v1, etc.

Add a new config option for 'b4 send', 'send-same-thread', defaulting to False, and read its value in get_prep_branch_as_patches. When True, add an 'In-Reply-To' header to the first mail in the series, referencing the Message-ID of the previous iterations's cover letter.

---
Changes in v2:
- removed the command-line flag and kept only the config, as suggested
by Konstantin
- Link to v1: https://msgid.link/20230219-send-iterations-in-same-thread-v1-0-59b802382eb5@gmail.com

v1:
Sending a new iteration of a series in the same thread as the previous one is the preferred workflow on some lists, the Git mailing list being an example [1].

This series allows that workflow in b4 by adding a '--same-thread' option to 'b4 send', with an associated config option.

Cheers,

Philippe.

[1] https://git-scm.com/docs/MyFirstContribution#v2-git-send-email

---
 b4/ez.py        | 7 +++++++
 docs/config.rst | 6 ++++++
 2 files changed, 13 insertions(+)
b4/ez.py +7 -0
index 74afddc..16e1cf8 100644
@@ -1191,6 +1191,13 @@ def get_prep_branch_as_patches(movefrom: bool = True, thread: bool = True, addtr
     if addtracking:
         patches[0][1].add_header('X-B4-Tracking', thdata)
 
+    samethread = config.get('send-same-thread', '').lower() in {'yes', 'true', 'y'}
+    if samethread and revision > 1:
+        oldrev = revision - 1
+        voldrev =  f'v{oldrev}'
+        oldmsgid =  tracking['series']['history'][voldrev][-1]
+        patches[0][1].add_header('In-Reply-To', f'<{oldmsgid}>')
+
     tag_msg = f'{csubject.full_subject}\n\n{cover_letter}'
     return alltos, allccs, tag_msg, patches
 
docs/config.rst +6 -0
index b3ab5ca..a1c424c 100644
@@ -351,6 +351,12 @@ Contributor-oriented settings
 
   Default:: ``scripts/get_maintainer.pl --nogit --nogit-fallback --nogit-chief-penguins --norolestats --nom``
 
+``b4.send-same-thread`` (v0.13+)
+  When sending a new version of a series, make it part of the same
+  thread as the previous one. The first mail will be sent as a reply
+  to the previous version's cover letter.
+
+  Default: ``no``
 
 ``b4.prep-cover-strategy`` (v0.10+)
   Alternative cover letter storage strategy to use (see :ref:`prep_cover_strategies`).

---
base-commit: a3281834d6d5dec44f58071fca2d22e04a97fe18
change-id: 20230219-send-iterations-in-same-thread-c50a3bc4ed9e --
b4

#7 lore raw
In reply to Philippe Blain
Quoted 8 lines · Philippe Blain

Sending a new iteration of a series in the same thread as the previous one is the preferred workflow on some lists, the Git mailing list being an example [1].

This series allows that workflow in b4 by adding a '--same-thread' option to 'b4 send', with an associated config option.

[...]

Applied, thanks!

[1/1] ez: allow sending all versions of a patch series in the same thread

      commit: 14a6165754778b83cdfb0b546f5bf23cecb84744

Best regards,

Signature · 1 line
Konstantin Ryabitsev <[email protected]>
#8 lore raw
Quoted 9 lines · Konstantin Ryabitsev
Quoted 4 lines

This series allows that workflow in b4 by adding a '--same-thread' option to 'b4 send', with an associated config option.

[...]

Applied, thanks!

[1/1] ez: allow sending all versions of a patch series in the same thread

      commit: 14a6165754778b83cdfb0b546f5bf23cecb84744

Hm... I found a bug in my own code. :) I took the v2 of the series, with slight modifications (which is why auto-matching failed).

Anyway, v2 is in.

-K