diff mbox series

[b4] ez: support shallow threads in "b4.send-same-thread"

Message ID 20241112-pks-shallow-threads-v1-1-79466a503075@pks.im (mailing list archive)
State New
Headers show
Series [b4] ez: support shallow threads in "b4.send-same-thread" | expand

Commit Message

Patrick Steinhardt Nov. 12, 2024, 10:20 a.m. UTC
When setting "b4.send-same-thread" to a truish value, B4 will send
revised versions of a patch series in the same thread. This is done by
setting the "In-Reply-To" header to the message ID of the cover letter
of the preceding version. This leads to "deep" nesting, where the nth
version of a series will be nested n-1 levels below the first version.

But not all projects prefer deep nesting. The alternative that is used
in some projects is "shallow" nesting: instead of nesting the rerolled
version under the preceding version's cover letter, it gets nested under
the first version's cover letter.

Implement support for a new "shallow" value for "b4.send-same-thread"
that does exactly this.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
I've recently started to experiment with B4 in the context of the Git
mailing list. Most folks over there don't use deep nesting for patch
series and instead prefer to shallowly nest patch series, which is what
this patch implements.
---
 docs/config.rst | 10 ++++++++--
 src/b4/ez.py    |  7 +++++--
 2 files changed, 13 insertions(+), 4 deletions(-)


---
base-commit: 355e82083f0eba59abf31521977dda09fab8bff5
change-id: 20241112-pks-shallow-threads-8d00bf73c752

Best regards,
diff mbox series

Patch

diff --git a/docs/config.rst b/docs/config.rst
index da58534a2ee24c453bee979f02949999069d8bc9..97271d663901bdca59ecfc26d88fa3d9e38ff1fe 100644
--- a/docs/config.rst
+++ b/docs/config.rst
@@ -398,8 +398,14 @@  Contributor-oriented settings
 
 ``b4.send-same-thread`` (v0.13+)
   When sending a new version of a series, send it in the same thread as
-  the previous version. B4 sends the first message of the new series as
-  a reply to the previous version's cover letter.
+  the previous version. The config supports the following values:
+
+  * ``yes``, ``true``, ``y``: B4 sends the first message of the new series as a
+    reply to the previous version's cover letter.
+  * ``shallow``: B4 sends the first message of the new series as a reply to the
+    first version's cover letter.
+  * ``no``: B4 does not send the new version of the series in the same thread
+    as any previous version.
 
   Default: ``no``
 
diff --git a/src/b4/ez.py b/src/b4/ez.py
index 970631592d2139b12ee4a6a9a112081eee1de721..3424c34e93361a432c5dc350a135e06ebf0fe0bc 100644
--- a/src/b4/ez.py
+++ b/src/b4/ez.py
@@ -1594,9 +1594,12 @@  def get_prep_branch_as_patches(movefrom: bool = True, thread: bool = True, addtr
     # Add X-Change-ID header
     patches[0][1].add_header('X-Change-ID', change_id)
 
-    samethread = config.get('send-same-thread', '').lower() in {'yes', 'true', 'y'}
-    if samethread and revision > 1:
+    samethread = config.get('send-same-thread', '').lower()
+    if samethread in {'yes', 'true', 'y', 'shallow'} and revision > 1:
         oldrev = revision - 1
+        if samethread == 'shallow':
+            oldrev = 1
+
         voldrev = f'v{oldrev}'
         try:
             oldmsgid = tracking['series']['history'][voldrev][-1]