From patchwork Sun Feb 22 15:42:45 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1926 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771775026; bh=DzEQDKZF+aeJAFkEYa/igqIgJ00QDSuUSZmB+bzCbvU=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=AiS9VFn1ujuKVO2PQeiGCVt5yGuyLCPqSCRYMrksM7ik0XIMSjLqEs6VYAxUVxznv tXNKJWRKzrwNHD51ZQqr4qw1lza3MJkrEPBluYSJ6f/pDpTf8auzR5pIZfV0xKSilG oz+KJ8zNZ1SFLZEHmpEK8Ds0bYRRaugnI7pcg4qx4EJzCJ6t8ygssnA69yD6MwnAjR iH3dMTkk2XanWakyqxYGnzZdloJSqNmAkNZS4VAApMLrytXbKUhSOB/VH8/11NFN4P VPdunucm3BfcmZ9TWzTVxn8Zv21HRTnhu3l88XDOLj2LZjSYpU+SrsImaZMaSS5IYz R0bwtJwQHlkQg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C602A69C5E for ; Sun, 22 Feb 2026 08:43:46 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id kRk1wPxuBekt for ; Sun, 22 Feb 2026 08:43:46 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771775026; bh=DzEQDKZF+aeJAFkEYa/igqIgJ00QDSuUSZmB+bzCbvU=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=AiS9VFn1ujuKVO2PQeiGCVt5yGuyLCPqSCRYMrksM7ik0XIMSjLqEs6VYAxUVxznv tXNKJWRKzrwNHD51ZQqr4qw1lza3MJkrEPBluYSJ6f/pDpTf8auzR5pIZfV0xKSilG oz+KJ8zNZ1SFLZEHmpEK8Ds0bYRRaugnI7pcg4qx4EJzCJ6t8ygssnA69yD6MwnAjR iH3dMTkk2XanWakyqxYGnzZdloJSqNmAkNZS4VAApMLrytXbKUhSOB/VH8/11NFN4P VPdunucm3BfcmZ9TWzTVxn8Zv21HRTnhu3l88XDOLj2LZjSYpU+SrsImaZMaSS5IYz R0bwtJwQHlkQg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B092E69D36 for ; Sun, 22 Feb 2026 08:43:46 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771775025; bh=Dn3430p5peK7cbOCKMHWpR1l8MM5lflgba7gifwQTEQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qCZ/YPWxNV0YYNOT2P3gGYcW2RY4iYh0Fh7pz1QaLNxouYH//ifIIsipAZcX5BFX2 bb9ElORmayQX/x9T/XrvnO7L9ScXb7FN8E3aZR1Fs3E56C4CJpOqCzcLvrXaa4Tqdg lnPhkACjReTkoAu6la0jA+jhq5r6E8v1NvRWL8bA2qnJBSFuQtwO7mXczPyEPhU+M+ iRvW6/kgh/TkQV1Abzhys0aNp4Jfi6SVZnkF7/RFE3/nZeqRfnNB+DM7qjlqLo8UPK VgPCarcvtj0lhTeHGXCJb4SGjOKRYJcVdQDcBlMjLMr6xaki3WQqW5mBma0YTyf2e4 Xo1AiaOjjrRKw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AF01B69C5E; Sun, 22 Feb 2026 08:43:45 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 2n3Jxw_GzmFj; Sun, 22 Feb 2026 08:43:45 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771775021; bh=w3VIP24Yj9ygJWv1VTAS4zvIRuj68XYuY58Yd7B4/Vs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pXYojOF8dIn+NZsf3aUyMgqlExsCaJABbCFwMj6IM31ZPrRZ6So13oMX52YwB4HAE zlQsM1fQnKuzKuPdxSKhTguz4YeyxLtgyW8fVhaNKwznXQsbmj2kiFjRSmFWdLiTDW wwYHQLw3yggy4VHCTgO15QHo6GLTod03jd8NBAAAja3ej0biSiVmlMfNVQjXKphsQ+ uqxPQDwsqXLx/m+rcS3j0eXfqEsM3/JIzcS09BZoyHMtLbG7CXGaJaRW+ESD2Uh85K oY2dKX+IWkHTDZBY9/KTJS0t6kQuaf0Mv4o5K+kNRCXyvpRhB+HX02BPdifc6cnbTT 4KlYNLzsYUE/w== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 38CB669C5C; Sun, 22 Feb 2026 08:43:41 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 22 Feb 2026 08:42:45 -0700 Message-ID: <20260222154303.2851319-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260222154303.2851319-1-sjg@u-boot.org> References: <20260222154303.2851319-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: AFXQGJL6QEIWBLR7247LW7HIEAKAWU7G X-Message-ID-Hash: AFXQGJL6QEIWBLR7247LW7HIEAKAWU7G X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 6" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 05/16] pickman: Refactor handle_already_applied() into smaller helpers List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Extract two helpers from handle_already_applied() to separate its functionality: - _applied_advance_source(): choose and set the new source position from the three possible cases (advance_to, signal_commit, last hash) - _applied_create_skip_mr(): push a skip branch and create the MR This reduces handle_already_applied() to a short sequence of mark, advance, and optionally push. Co-developed-by: Claude Opus 4.6 Signed-off-by: Simon Glass --- tools/pickman/control.py | 101 ++++++++++++++++++++++----------------- 1 file changed, 58 insertions(+), 43 deletions(-) diff --git a/tools/pickman/control.py b/tools/pickman/control.py index 19cd2813b64..39ce57d0895 100644 --- a/tools/pickman/control.py +++ b/tools/pickman/control.py @@ -1539,6 +1539,60 @@ def prepare_apply(dbs, source, branch): # pylint: disable=too-many-arguments +def _applied_advance_source(dbs, source, commits, advance_to, + signal_commit): + """Advance the source position after skipping already-applied commits. + + Chooses the new position from advance_to, signal_commit, or the + last commit hash, in that priority order. + """ + if advance_to is not None: + new_hash = advance_to + elif signal_commit: + new_hash = signal_commit + else: + new_hash = commits[-1].hash + + dbs.source_set(source, new_hash) + dbs.commit() + tout.info(f"Updated source '{source}' to {new_hash[:12]}") + + +def _applied_create_skip_mr(args, source, commits, branch_name, conv_log): + """Push a skip branch and create an MR recording the skip. + + Returns: + int: 0 on success, 1 on failure + """ + remote = args.remote + target = args.target + + try: + run_git(['checkout', '-b', branch_name, f'{remote}/{target}']) + except Exception: # pylint: disable=broad-except + # Branch may already exist from failed attempt + try: + run_git(['checkout', branch_name]) + except Exception: # pylint: disable=broad-except + tout.error(f'Could not create/checkout branch {branch_name}') + return 1 + + title = f'{SKIPPED_TAG} [pickman] {commits[-1].subject}' + summary = format_history(source, commits, branch_name) + description = (f'{summary}\n\n' + f'**Status:** Commits already applied to {target} ' + f'with different hashes.\n\n' + f'### Conversation log\n{conv_log}') + + mr_url = gitlab_api.push_and_create_mr( + remote, branch_name, target, title, description + ) + if not mr_url: + return 1 + + return 0 + + def handle_already_applied(dbs, source, commits, branch_name, conv_log, args, signal_commit, advance_to=None): """Handle the case where commits are already applied to the target branch @@ -1563,55 +1617,16 @@ def handle_already_applied(dbs, source, commits, branch_name, conv_log, args, """ tout.info('Commits already applied to target branch - creating skip MR') - # Mark commits as 'skipped' in database for commit in commits: dbs.commit_set_status(commit.hash, 'skipped') dbs.commit() - # Update source position - if advance_to is not None: - dbs.source_set(source, advance_to) - dbs.commit() - tout.info(f"Updated source '{source}' to {advance_to[:12]}") - elif signal_commit: - dbs.source_set(source, signal_commit) - dbs.commit() - tout.info(f"Updated source '{source}' to {signal_commit[:12]}") - else: - last_hash = commits[-1].hash - dbs.source_set(source, last_hash) - dbs.commit() - tout.info(f"Updated source '{source}' to {last_hash[:12]}") + _applied_advance_source(dbs, source, commits, advance_to, + signal_commit) - # Push and create MR with [skip] prefix if requested if args.push: - remote = args.remote - target = args.target - - # Create a skip branch from ci/master (no changes) - try: - run_git(['checkout', '-b', branch_name, f'{remote}/{target}']) - except Exception: # pylint: disable=broad-except - # Branch may already exist from failed attempt - try: - run_git(['checkout', branch_name]) - except Exception: # pylint: disable=broad-except - tout.error(f'Could not create/checkout branch {branch_name}') - return 1 - - # Use merge commit subject as title with [skip] prefix - title = f'{SKIPPED_TAG} [pickman] {commits[-1].subject}' - summary = format_history(source, commits, branch_name) - description = (f'{summary}\n\n' - f'**Status:** Commits already applied to {target} ' - f'with different hashes.\n\n' - f'### Conversation log\n{conv_log}') - - mr_url = gitlab_api.push_and_create_mr( - remote, branch_name, target, title, description - ) - if not mr_url: - return 1 + return _applied_create_skip_mr(args, source, commits, + branch_name, conv_log) return 0