From patchwork Sun Feb 22 15:42:43 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1924 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=1771775018; bh=DpKqgQI1pGBdaV+4C/LzvnUwaKnGJYHy/+UrSJcqSNI=; 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=db1qKLmvXdBu5lAJvdlVwht5fyC7YSRWsFKR36daDdM9giLZy78lxj56rOjT/L6em VoULBq1UdCQ2Z8BeXsSlrauGR/U13PncVPC8bE7tnc1JQ7rqgrzoIz84rts0YjbF9r mIH0eRLIaEmGwynX+8Pjh/3In6TC5rTlOGt0Lq9eQPocrju2K0tuOpGcWPIKZcRdKE d/mwt7/DK89LhosJWqExj1F7q28XirdnQSQs8l5SoW92vauMp0i4jit3GLc21bwU1j f1MryWJXwA7BPmYgFiXgNQk4vrBQlqS2PTJQLcBE5n2M22ibFSF2hYgQZvplPXWPBg 5AIDr3iN1uSQA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EDC1E69C78 for ; Sun, 22 Feb 2026 08:43:38 -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 QdTk0v9MR_4H for ; Sun, 22 Feb 2026 08:43:38 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771775018; bh=DpKqgQI1pGBdaV+4C/LzvnUwaKnGJYHy/+UrSJcqSNI=; 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=db1qKLmvXdBu5lAJvdlVwht5fyC7YSRWsFKR36daDdM9giLZy78lxj56rOjT/L6em VoULBq1UdCQ2Z8BeXsSlrauGR/U13PncVPC8bE7tnc1JQ7rqgrzoIz84rts0YjbF9r mIH0eRLIaEmGwynX+8Pjh/3In6TC5rTlOGt0Lq9eQPocrju2K0tuOpGcWPIKZcRdKE d/mwt7/DK89LhosJWqExj1F7q28XirdnQSQs8l5SoW92vauMp0i4jit3GLc21bwU1j f1MryWJXwA7BPmYgFiXgNQk4vrBQlqS2PTJQLcBE5n2M22ibFSF2hYgQZvplPXWPBg 5AIDr3iN1uSQA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CFD6369D36 for ; Sun, 22 Feb 2026 08:43:38 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771775017; bh=MIgOS9leFemDDFvaDo+pnZcm9M8Vi67L8Nb0I/0gEoU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sRbz4EzxBXTLWt8aD3Svr2fDHYVGy9pICnf+/EWAUOGfRFRT5f+Loz6OFx1mqKpFk 7kCrYcteKG9Q9HQ+jQAjQrWpLRyexKKfT5IFLoXhA7w+ldIDV0A1VJ3jmfQ1fo025d wKvYe/i94rOBhU+hPum9w8GuFZf3uMBMihHpTQI/nUTaxvTP4xS293Hbor9cyB/aNK GOjGFwQ57rSk0+SxwHIUkbFPSm1nUjJqkYW1x4TnJefqkQYYtimHNKFa279z6Elqjw 9Wej/DBnBNWrSKIvB6PTizjIaOuj4eQgYrRbWRZMzQJ3Mt8ebOsLwZOkcvY8IUXNOi pHrw/RSZs3bXQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0346169D36; Sun, 22 Feb 2026 08:43:37 -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 ihWKczMkYt9w; Sun, 22 Feb 2026 08:43:36 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771775011; bh=s0QbEkr+7U7mnlDxPxO1cRO/q2VTnoS7mr3voGD4SNU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bdpU7WkzSdiz+3Ve6BJo11/7PZWTux+pnYyV1iDvRhkeVIEVGpEZKZGlakiLjKMoI pYPXGHWlgP8uRebFcXgeJC9MRba0+ymQSCvidv6ivFw6YVv+62dQFhqjqnIHFBmzgj nj2bNlot2PYeE3CAl2YFoQBKixQfK/fkc4HTkTeEhk8ILJ2GmmsGPXdHPN/sJv+cnT s1o9cM9i8qYS+NvohSzpJQwbqtvgglSf4iBDJinm41E2rdLAWVIbfQxTBUyQU4KZZr ug4ZV3bz2PaenLMf8ZCEoomxM22MxR8GppkkpyEk8/xfHxHx4ccrgYHVEa8qmY/Jwq AnAzeR7g0uvAA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id AA43F69C78; Sun, 22 Feb 2026 08:43:31 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 22 Feb 2026 08:42:43 -0700 Message-ID: <20260222154303.2851319-4-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: H4SED5CXOPVO4IEAJ2XZU3BTRRGXAW7O X-Message-ID-Hash: H4SED5CXOPVO4IEAJ2XZU3BTRRGXAW7O 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 03/16] pickman: Refactor do_next_merges() 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 do_next_merges() mixes fetching, display-building and output in a single function. Extract three private helpers that each handle one phase: - _next_fetch_merges(): fetch and parse merge commits from git log - _next_build_display(): expand mega-merges into sub-merge display entries - _next_show_merges(): print the formatted listing This reduces do_next_merges() to ~20 lines of sequential calls. Co-developed-by: Claude Opus 4.6 Signed-off-by: Simon Glass --- tools/pickman/control.py | 72 +++++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 23 deletions(-) diff --git a/tools/pickman/control.py b/tools/pickman/control.py index 868e03df8c9..d3cb8a8fff4 100644 --- a/tools/pickman/control.py +++ b/tools/pickman/control.py @@ -1081,27 +1081,12 @@ def do_next_set(args, dbs): return 0 -def do_next_merges(args, dbs): - """Show the next N merges to be applied from a source - - Args: - args (Namespace): Parsed arguments with 'source' and 'count' attributes - dbs (Database): Database instance +def _next_fetch_merges(last_commit, source, count): + """Fetch the next merge commits from a source. Returns: - int: 0 on success, 1 if source not found + list: (hash, short_hash, subject) tuples, up to count entries """ - source = args.source - count = args.count - - # Get the last cherry-picked commit from database - last_commit = dbs.source_get(source) - - if not last_commit: - tout.error(f"Source '{source}' not found in database") - return 1 - - # Find merge commits on the first-parent chain out = run_git([ 'log', '--reverse', '--first-parent', '--merges', '--format=%H|%h|%s', @@ -1109,8 +1094,7 @@ def do_next_merges(args, dbs): ]) if not out: - tout.info('No merges remaining') - return 0 + return [] merges = [] for line in out.split('\n'): @@ -1124,9 +1108,18 @@ def do_next_merges(args, dbs): if len(merges) >= count: break - # Build display list, expanding mega-merges into sub-merges - # Each entry is (chash, subject, is_mega, sub_list) where sub_list - # is a list of (chash, subject) for mega-merge sub-merges + return merges + + +def _next_build_display(merges): + """Build display list, expanding mega-merges into sub-merges. + + Each entry is (chash, subject, is_mega, sub_list) where sub_list + is a list of (chash, subject) for mega-merge sub-merges. + + Returns: + tuple: (display_list, total_sub_count) + """ display = [] total_sub = 0 for commit_hash, chash, subject in merges: @@ -1149,6 +1142,11 @@ def do_next_merges(args, dbs): else: display.append((chash, subject, False, None)) + return display, total_sub + + +def _next_show_merges(source, merges, display, total_sub): + """Display the next-merges listing.""" n_items = total_sub + len(merges) - len( [d for d in display if d[2]]) tout.info(f'Next merges from {source} ' @@ -1165,6 +1163,34 @@ def do_next_merges(args, dbs): tout.info(f' {idx}. {chash} {subject}') idx += 1 + +def do_next_merges(args, dbs): + """Show the next N merges to be applied from a source + + Args: + args (Namespace): Parsed arguments with 'source' and 'count' attributes + dbs (Database): Database instance + + Returns: + int: 0 on success, 1 if source not found + """ + source = args.source + count = args.count + + last_commit = dbs.source_get(source) + if not last_commit: + tout.error(f"Source '{source}' not found in database") + return 1 + + merges = _next_fetch_merges(last_commit, source, count) + if not merges: + tout.info('No merges remaining') + return 0 + + display, total_sub = _next_build_display(merges) + + _next_show_merges(source, merges, display, total_sub) + return 0