[Concept,17/29] patman: Abort review on partial or interrupted apply

Message ID 20260501110040.1874719-18-sjg@u-boot.org
State New
Headers
Series patman: Review-flow improvements and shared helpers |

Commit Message

Simon Glass May 1, 2026, 11 a.m. UTC
  From: Simon Glass <sjg@chromium.org>

When the apply agent finishes successfully but only some of the
patches actually land on the review branch, the subsequent review
runs against an incomplete series and produces confusing output: the
cover letter claims N patches but only M commits exist.

Compare the applied count from gitutil.count_revs() against
patch_count and abort with a clear message when they differ, asking
the user to resolve the conflicts manually and retry. The 'no
commits' case (None from count_revs(), or zero) already routes
through the existing failure path that rolls back the database and
restores the original branch.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/patman/review.py | 6 ++++++
 1 file changed, 6 insertions(+)
  

Patch

diff --git a/tools/patman/review.py b/tools/patman/review.py
index 66580e48ee6..8af13b65711 100644
--- a/tools/patman/review.py
+++ b/tools/patman/review.py
@@ -1632,6 +1632,12 @@  def _apply_and_check(ctx, link):
         applied = gitutil.count_revs(
             repo_path, f'{ctx.upstream_branch}..{branch_name}')
         if not applied:
+            # Zero commits, or branch missing because apply was interrupted
+            success = False
+        elif applied != ctx.patch_count:
+            tout.error(f'Only {applied} of {ctx.patch_count} patches '
+                       f'applied to {branch_name}; aborting. Fix the '
+                       'conflicts manually and retry.')
             success = False
 
     if not success: