Skip to contentSkip to conversation

review: Preserve waiting series without a review branch

PATCH New Jason Gunthorpe 1 participant 1 message Nov 20

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 review: Preserve waiting series without a review branch

A new series can be marked waiting before a review branch is created. For example if something happened on the mailing list that warrants deferring reviewing it until a new version. Full rescans currently treat that absent branch as deleted and mark the series gone.

Require a previously recorded branch SHA before marking a waiting series gone. Keep detecting deleted branches for waiting series that have been scanned, and cover both cases with regression tests.

Assisted-by LLM
---
 src/b4/review/tracking.py         | 16 ++++++---
 src/tests/test_review_tracking.py | 54 +++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+), 5 deletions(-)

I've been testing this for a little while here and it seems to be solving the problem I hit.

src/b4/review/tracking.py +11 -5
index 4d2cc2fdd3120c..c887c798395fbc 100644
@@ -3362,16 +3362,22 @@ def rescan_branches(
     # Full rescan: mark missing branches as "gone"
     gone = 0
     if not branch:
-        all_series = get_all_tracked_series(identifier)
-        active_statuses = ('reviewing', 'replied', 'partial', 'waiting')
+        # Waiting can be set directly from new, without creating a branch.
+        # Only treat a waiting series as missing if a prior scan recorded
+        # its branch SHA; otherwise there is no evidence of a deleted branch.
+        all_series = conn.execute(
+            'SELECT change_id, revision FROM series'
+            " WHERE status IN ('reviewing', 'replied', 'partial', 'waiting')"
+            " AND (status != 'waiting' OR branch_sha IS NOT NULL)"
+        ).fetchall()
         for s in all_series:
-            sid = s.get('change_id')
+            sid = s['change_id']
             if not sid:
                 continue
-            if s.get('status') in active_statuses and sid not in scanned_change_ids:
+            if sid not in scanned_change_ids:
                 branch_name = f'b4/review/{sid}'
                 if not b4.git_branch_exists(topdir, branch_name):
-                    update_series_status(conn, sid, 'gone', revision=s.get('revision'))
+                    update_series_status(conn, sid, 'gone', revision=s['revision'])
                     logger.info('Marked as gone: %s', sid)
                     gone += 1
 
src/tests/test_review_tracking.py +54 -0

60 lines not on this page · raw message

base-commit: 1b309be67793a389c65db822a109b811b89b9dcb

Signature · 1 line
2.43.0