Linux maintainer tooling and workflows
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: "Kernel.org Tools" <tools@kernel.org>
Cc: Konstantin Ryabitsev <konstantin@linuxfoundation.org>,
	 "Christian Brauner (Amutable)" <brauner@kernel.org>
Subject: [PATCH RFC v2 03/25] review-tui: keep the rethread flag on an upgraded series row
Date: Wed, 12 Aug 2026 23:46:44 +0200	[thread overview]
Message-ID: <20260812-work-b4-multiver-rows-v2-3-305d53cd723a@kernel.org> (raw)
In-Reply-To: <20260812-work-b4-multiver-rows-v2-0-305d53cd723a@kernel.org>

The upgrade path resolves whether the target revision needs rethreading
and threads target_is_rethreaded through five call sites, then does not
pass it to add_series_to_db().  The UPSERT arm writes is_rethreaded from
the excluded row, so the parameter's False default lands on the row and
clears an existing 1.

A series row saying 0 for a revision that really was stitched together
from individually fetched patches sends retrieve_series_messages() down
the single-msgid path: 'e' shows one patch's thread instead of the
series, and the message count collapses to match.

Pass the flag the upgrade already computed, and stop depending on every
caller remembering to.  The flag describes the posting, which the
revisions catalog already records, so resolve it from there on the way in
and keep the argument for a first track, before there is a catalog row to
ask.  Make the UPSERT arm sticky rather than overwriting, as
add_revision() already is.

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
 src/b4/review/tracking.py          | 20 +++++++++++++++++---
 src/b4/review_tui/_tracking_app.py |  6 ++++++
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/src/b4/review/tracking.py b/src/b4/review/tracking.py
index 52b9a897..710b4a0d 100644
--- a/src/b4/review/tracking.py
+++ b/src/b4/review/tracking.py
@@ -456,7 +456,16 @@ def add_series_to_db(
     an existing one in place.  Re-adds come from callers that never
     learned those fields -- the Patchwork tracker attaching its id,
     rescan_branches replaying a branch -- and each used to wipe whatever
-    the others had recorded.
+    the others had recorded.  ``is_rethreaded`` is sticky for the same
+    reason, matching the catalog's :func:`add_revision`.
+
+    ``is_rethreaded`` describes the posting, so the catalog's answer for
+    this revision wins over the argument on the way in.  The argument is
+    still what a first track supplies, before there is a catalog row to
+    ask.  Callers that hand-carry the flag from a catalog lookup are then
+    merely agreeing with the row rather than being the only thing standing
+    between it and a False default -- which is what made dropping it at
+    one call site quietly clear the column.
     """
     if added_at is None:
         added_at = datetime.datetime.now(datetime.timezone.utc).isoformat()
@@ -465,7 +474,9 @@ def add_series_to_db(
         INSERT INTO series
         (change_id, revision, subject, sender_name, sender_email, sent_at, added_at,
          message_id, num_patches, pw_series_id, fingerprint, is_rethreaded)
-        VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
+        VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
+                MAX(?, COALESCE((SELECT is_rethreaded FROM revisions
+                                 WHERE change_id = ? AND revision = ?), 0)))
         ON CONFLICT (change_id, revision) DO UPDATE SET
             subject = excluded.subject,
             sender_name = excluded.sender_name,
@@ -476,7 +487,8 @@ def add_series_to_db(
             num_patches = excluded.num_patches,
             pw_series_id = COALESCE(excluded.pw_series_id, series.pw_series_id),
             fingerprint = COALESCE(excluded.fingerprint, series.fingerprint),
-            is_rethreaded = excluded.is_rethreaded
+            is_rethreaded = MAX(COALESCE(series.is_rethreaded, 0),
+                                excluded.is_rethreaded)
         RETURNING track_id
     """,
         (
@@ -492,6 +504,8 @@ def add_series_to_db(
             pw_series_id,
             fingerprint,
             int(is_rethreaded),
+            change_id,
+            revision,
         ),
     )
     track_id = cursor.fetchone()[0]
diff --git a/src/b4/review_tui/_tracking_app.py b/src/b4/review_tui/_tracking_app.py
index 9f0a0302..69da8f58 100644
--- a/src/b4/review_tui/_tracking_app.py
+++ b/src/b4/review_tui/_tracking_app.py
@@ -4462,6 +4462,12 @@ class TrackingApp(LoreNodeShutdownMixin, CheckRunnerMixin, App[Optional[str]]):
                         sent_at,
                         target_msgid,
                         lser.expected or num_am,
+                        # The upgrade already resolved this; without it the
+                        # UPSERT writes the column's 0 default (and clears an
+                        # existing 1), which sends every later retrieval of
+                        # the now-tracked revision down the single-msgid path
+                        # instead of reassembling it from its member patches.
+                        is_rethreaded=bool(target_is_rethreaded),
                     )
                     b4.review.tracking.update_series_status(
                         conn, change_id, 'reviewing', revision=target_rev

-- 
2.53.0


  parent reply	other threads:[~2026-08-12 21:47 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-12 21:46 [PATCH RFC v2 00/25] review: track and browse every version of a tracked series Christian Brauner
2026-08-12 21:46 ` [PATCH RFC v2 01/25] review-tui: fix rethreaded series thread viewing Christian Brauner
2026-08-12 21:46 ` [PATCH RFC v2 02/25] review: do not clear fields a re-adding caller does not know Christian Brauner
2026-08-12 21:46 ` Christian Brauner [this message]
2026-08-12 21:46 ` [PATCH RFC v2 04/25] review: guard the tracking-commit amend on the worktree, not the checkout Christian Brauner
2026-08-12 21:46 ` [PATCH RFC v2 05/25] review-tui: recompute an evicted A·R·T cache entry Christian Brauner
2026-08-12 21:46 ` [PATCH RFC v2 06/25] review: test the prerequisite fixes Christian Brauner
2026-08-12 21:46 ` [PATCH RFC v2 07/25] review: serialize schema migrations against a concurrent opener Christian Brauner
2026-08-12 21:46 ` [PATCH RFC v2 08/25] review: test the migration serialization Christian Brauner
2026-08-12 21:46 ` [PATCH RFC v2 09/25] review: track message counts for all revisions of a series Christian Brauner
2026-08-12 21:46 ` [PATCH RFC v2 10/25] review: give per-change_id state its own table Christian Brauner
2026-08-12 21:46 ` [PATCH RFC v2 11/25] review: test per-revision message tracking Christian Brauner
2026-08-12 21:46 ` [PATCH RFC v2 12/25] review-tui: poll every revision on u/U updates Christian Brauner
2026-08-12 21:46 ` [PATCH RFC v2 13/25] review: test the per-revision poll sweep Christian Brauner
2026-08-12 21:46 ` [PATCH RFC v2 14/25] review-tui: resolve the tracked revision in revision lists Christian Brauner
2026-08-12 21:46 ` [PATCH RFC v2 15/25] review-tui: fall back when a cached thread blob has no series Christian Brauner
2026-08-12 21:46 ` [PATCH RFC v2 16/25] review-tui: test revision resolution and the range-diff fallback Christian Brauner
2026-08-12 21:46 ` [PATCH RFC v2 17/25] review: skip the catalog mirror when nothing moved Christian Brauner
2026-08-12 21:46 ` [PATCH RFC v2 18/25] review: match a stray posting by message-id Christian Brauner
2026-08-12 21:47 ` [PATCH RFC v2 19/25] review: add backward discovery of older series revisions Christian Brauner
2026-08-12 21:47 ` [PATCH RFC v2 20/25] review-tui: add a "Find older revisions" action Christian Brauner
2026-08-12 21:47 ` [PATCH RFC v2 21/25] review: test the catalog mirror, stray matching and backward discovery Christian Brauner
2026-08-12 21:47 ` [PATCH RFC v2 22/25] review-tui: extract the Msgs column renderer from TrackedSeriesItem Christian Brauner
2026-08-12 21:47 ` [PATCH RFC v2 23/25] review-tui: give the unseen badge a column of its own Christian Brauner
2026-08-12 21:47 ` [PATCH RFC v2 24/25] review-tui: expand tracked series into per-version rows Christian Brauner
2026-08-12 21:47 ` [PATCH RFC v2 25/25] review-tui: test per-version tracker rows Christian Brauner

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260812-work-b4-multiver-rows-v2-3-305d53cd723a@kernel.org \
    --to=brauner@kernel.org \
    --cc=konstantin@linuxfoundation.org \
    --cc=tools@kernel.org \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox