review: Send replies for skipped patches
PATCH 1/1 review: Send replies for skipped patches
Currently when a patch is skipped this includes for email mode, even if a reply has been written. This seems unhelpful, if the user has written something it seems reasonable they would want to send it and if they want to not send a reply they can always delete it. Skipping also affects patch application and one reason a user might reply to a patch is to explain why they are not taking it.
Change the behaviour so that replies are also sent for skipped patches.
--- docs/maintainer/review.rst | 5 +-- src/b4/review/_review.py | 12 +++---- src/b4/review_tui/_review_app.py | 22 +++--------- src/tests/test_review.py | 20 +++++------ src/tests/test_tui_review.py | 77 +++++++++++++++++++++++++++++++++++++++- 5 files changed, 96 insertions(+), 40 deletions(-)
docs/maintainer/review.rst +3 -2
@@ -760,7 +760,7 @@ Unchanged ``≡`` — Patch identical to prior revision (auto, on upgr External ``±`` — External reviewers have inline comments (auto) Draft ``✎`` — You have comments, a reply, or a nack trailer (auto) Done ``✓`` ``d`` Review complete, include in outgoing emails (also auto) -Skip ``✕`` ``x`` Intentionally skipped, exclude from outgoing emails +Skip ``✕`` ``x`` Intentionally skipped; any replies are still sent ========== ====== ====== ======================================================= .. |sp| unicode:: U+0020
@@ -788,7 +788,8 @@ bold, skipped and unchanged patches appear dimmed. Press ``H`` to hide skipped patches from the list entirely — useful for large series where many patches are irrelevant to your review. -Skipped patches are automatically excluded when sending review emails. +Any unsent replies, comments, or trailers on skipped patches are still +included when previewing and sending review emails. When taking patches via cherry-pick, skipped patches are pre-deselected in the patch selection dialog.
src/b4/review/_review.py +4 -8
@@ -3914,8 +3914,8 @@ def collect_review_emails( ) -> List[email.message.EmailMessage]: """Collect review emails to send for the given series. - Only sends the maintainer's own reviews, not agent or other - reviewers' data. + Only sends the maintainer's own unsent reviews, not agent or other + reviewers' data. Skipped patches can still have replies to send. """ usercfg = b4.get_user_config() my_email = str(usercfg.get('email', '[email protected]'))
@@ -3923,11 +3923,7 @@ def collect_review_emails( # Cover letter review (maintainer only) cover_review = series.get('reviews', {}).get(my_email, {}) - if ( - cover_review - and cover_review.get('patch-state') != 'skip' - and cover_review.get('sent-revision') is None - ): + if cover_review and cover_review.get('sent-revision') is None: msg = _build_review_email(series, None, cover_review, cover_text, topdir, None) if msg is not None: msgs.append(msg)
@@ -3935,7 +3931,7 @@ def collect_review_emails( # Per-patch reviews (maintainer only) for idx, patch_meta in enumerate(patches): patch_review = patch_meta.get('reviews', {}).get(my_email, {}) - if not patch_review or patch_review.get('patch-state') == 'skip': + if not patch_review: continue if patch_review.get('sent-revision') is not None: continue
src/b4/review_tui/_review_app.py +4 -18
@@ -857,22 +857,6 @@ class ReviewApp(LoreNodeShutdownMixin, CheckRunnerMixin, App[None]): else None ) - target = self._series if display_idx == 0 else patch_meta - if target and b4.review._get_patch_state(target, self._usercfg) == 'skip': - total = len(self._commit_shas) - label = 'cover' if display_idx == 0 else f'{display_idx}/{total}' - my_review = b4.review._get_my_review(target, self._usercfg) - skip_reason = str(my_review.get('skip-reason', '')) - if skip_reason: - viewer.write( - f'[dim]Patch {label} is marked as skipped: {skip_reason}[/dim]' - ) - else: - viewer.write( - f'[dim]Patch {label} is marked as skipped — no email will be sent.[/dim]' - ) - return - if not review or not ( review.get('trailers') or review.get('reply', '') or review.get('comments') ):
@@ -1805,15 +1789,17 @@ class ReviewApp(LoreNodeShutdownMixin, CheckRunnerMixin, App[None]): try: self._reply_sent = True self._tracking['series']['status'] = 'replied' - # Stamp sent-revision on every non-skip review so that + # Stamp sent-revision on each review whose email was sent so that # if this series is later upgraded to a newer revision, # the upgrade step can detect which reviews were already # sent and auto-skip the unchanged patches. my_email = str(self._usercfg.get('email', '[email protected]')) current_rev = int(self._series.get('revision', 1)) + replied_to = {msg['In-Reply-To'] for msg in msgs} for target in [self._series] + list(self._patches): review = target.get('reviews', {}).get(my_email, {}) - if review and review.get('patch-state') != 'skip': + msgid = target.get('header-info', {}).get('msgid', '') + if review and f'<{msgid}>' in replied_to: review['sent-revision'] = current_rev if not self._save_tracking(): # Silence here means the next session offers these reviews
src/tests/test_review.py +9 -11
@@ -4212,10 +4212,11 @@ class TestCollectReviewEmails: pytest.param(False, id='normal-patch-review'), ], ) + @pytest.mark.parametrize('patch_state', ['', 'done', 'skip']) def test_sends_unsent_review( - self, _cfg: mock.Mock, _build: mock.Mock, on_cover: bool + self, _cfg: mock.Mock, _build: mock.Mock, on_cover: bool, patch_state: str ) -> None: - msgs = self._collect(on_cover, {}) + msgs = self._collect(on_cover, {'patch-state': patch_state}) assert len(msgs) == 1 @pytest.mark.parametrize(
@@ -4225,10 +4226,8 @@ class TestCollectReviewEmails: pytest.param(True, {'sent-revision': 1}, id='cover-with-sent-revision'), pytest.param(False, {'sent-revision': 1}, id='patch-with-sent-revision'), # The upgrade step sets patch-state=skip AND skip-reason on - # unchanged patches whose review was already sent (combo A+B - # fix). Both the skip filter and the sent-revision filter - # independently prevent re-sending; this row exercises the - # skip-state path. + # unchanged patches whose review was already sent. The + # sent-revision filter must still prevent re-sending them. pytest.param( False, {
@@ -4238,15 +4237,14 @@ class TestCollectReviewEmails: }, id='patch-auto-skipped-after-upgrade', ), - # Explicit skip state (manually set, no sent-revision) is honoured. pytest.param( - False, - {'patch-state': 'skip'}, - id='skip-state-without-sent-revision', + True, + {'sent-revision': 1, 'patch-state': 'skip'}, + id='skipped-cover-with-sent-revision', ), ], ) - def test_skips_already_sent_or_skipped( + def test_skips_already_sent( self, _cfg: mock.Mock, _build: mock.Mock,
src/tests/test_tui_review.py +76 -1
89 lines not on this page · raw message
---
base-commit: ce4c1158edb292caca0ce4a6087e5edecc1b0371
change-id: 20261111-reply-skipped-325b3debc6f4
Best regards,
Signature · 1 line
Mark Brown <[email protected]>
Quoted 8 lines
Currently when a patch is skipped this includes for email mode, even if a reply has been written. This seems unhelpful, if the user has written something it seems reasonable they would want to send it and if they want to not send a reply they can always delete it. Skipping also affects patch application and one reason a user might reply to a patch is to explain why they are not taking it.
Change the behaviour so that replies are also sent for skipped patches.
Applied with a few minor tweaks, plus a fix that I found along the way.
Thanks!
Signature · 1 line
Konstantin Ryabitsev <[email protected]>