From patchwork Thu Feb 12 21:16:20 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1845 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=1770931033; bh=KaMBMSS48Y4jbKzMkWA0m53iC0fFIDJtRxUczVbxFIA=; 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=gYFfXCeVwo6W9fVLCTEdqxx1b0/14xzlN41DSQyDpjLlBnWaiktJw5aUvcwrShQt3 VQuc5Ym/rloMYJsdQ4K7MWypI8/MVwmswXzSy5/5BaQ7toGpjMhmkNd6/6WQNmsLPH 3dX0CVFXNo8+d1oA/4wfKsJJ9fF4YApU13ciDuBI0SZrgN4mku6IFwIJgV4YAsm5EN QxtxjCri9u0VEmsAXP+KX6YFfRamfa+xyDsANYaRGUOGtXPo2dW9HBRijUw/Iqf8tU JEY1bAkWpX3PqdRW6jMFttwL1HYVdAht5VsZ+OOYGrPQRgpiz7/Pg+ArB/i9zQLFKm x6ErdYyKV8xhA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2AB7D69ABF for ; Thu, 12 Feb 2026 14:17:13 -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 t8ayOgi3AkM3 for ; Thu, 12 Feb 2026 14:17:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770931033; bh=KaMBMSS48Y4jbKzMkWA0m53iC0fFIDJtRxUczVbxFIA=; 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=gYFfXCeVwo6W9fVLCTEdqxx1b0/14xzlN41DSQyDpjLlBnWaiktJw5aUvcwrShQt3 VQuc5Ym/rloMYJsdQ4K7MWypI8/MVwmswXzSy5/5BaQ7toGpjMhmkNd6/6WQNmsLPH 3dX0CVFXNo8+d1oA/4wfKsJJ9fF4YApU13ciDuBI0SZrgN4mku6IFwIJgV4YAsm5EN QxtxjCri9u0VEmsAXP+KX6YFfRamfa+xyDsANYaRGUOGtXPo2dW9HBRijUw/Iqf8tU JEY1bAkWpX3PqdRW6jMFttwL1HYVdAht5VsZ+OOYGrPQRgpiz7/Pg+ArB/i9zQLFKm x6ErdYyKV8xhA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 18F8769AD8 for ; Thu, 12 Feb 2026 14:17:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770931030; bh=KvMPtMskO4N2wf8jRYAhkkmXX2bNVfP2LbY5me6xyfU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nJ53bN7X+4xkfiehVv/R696dcCXAgmik8o89LPh5m/RoCmILtQidL7JvHPCesvKPu f83DZcAjUNVL5Dy+j1jei5Uekb/U1r0A7jQWnuwfAXAqpqPd019iSMG3DpLO1cQCch sASNW0qXDy9A/2E8mV7dm7H3fwnzNJlXdFnod+IQkJMxc4rJ2RCs12P0LwY5JF73b2 r0U3EillEwGuIuxNtg9RmL8juUrZucaOykbfqjQb+zv/6E5PkaBQGK1KPIOOwPWS8t X/DjiED7cni2aW8gmb89YDQ85cEgzK0/BUOLDVGVP2VTaDF1mZCODjwH0OvmLKK9Ja 3le65QqXpfZtA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EF3B369ABF; Thu, 12 Feb 2026 14:17:10 -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 4lRZVKEmbDdA; Thu, 12 Feb 2026 14:17:10 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770931026; bh=0EW9cJJMPmhrED97bWFL3ugbqoYnDSL3ynqlkWYsZtI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XaKtF3jKZyu/yOdBZOwmu5yxIgnajQ3jw+1aHGMDGYezIUpHml5BtyGRI8y0HLFf3 R2o8UL0lWxA3pFhZlSOA0gs9Tnbwrb2rgG21em+g7Eez7KNV+qMNjoxY969LYuhghg q+sU+Ip1m/eJ2ba2GA3f7GbdwuH1hI9E8vU6sWNYWsBEWdRzF2obcyfT3TD4BiXKk1 pTEte2PxtHTj8amXHgp3fTM8nFRuLFYY2Q/xbCUQXS+2srW+x9e5MzzSaL/x74WDE+ yfJlgp6CRc/IzZLHpx2f/AKYOhMA0utL3+Gvr9LaHhu357WMdXCU1s/VRwD2VhsQPB XU3at4pBjkPdQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 82EC16994D; Thu, 12 Feb 2026 14:17:06 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 12 Feb 2026 14:16:20 -0700 Message-ID: <20260212211626.167191-8-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260212211626.167191-1-sjg@u-boot.org> References: <20260212211626.167191-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 5CLAYXS6DJ4IXKXFUXKYL3YWY664KTV4 X-Message-ID-Hash: 5CLAYXS6DJ4IXKXFUXKYL3YWY664KTV4 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 7/9] pickman: Extract find_unprocessed_commits() from get_next_commits() 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 Move the merge-walking loop into its own function to reduce the complexity of get_next_commits() Co-developed-by: Claude Opus 4.6 Signed-off-by: Simon Glass --- tools/pickman/control.py | 91 ++++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 36 deletions(-) diff --git a/tools/pickman/control.py b/tools/pickman/control.py index cd138612623..0418fbe2da6 100644 --- a/tools/pickman/control.py +++ b/tools/pickman/control.py @@ -745,6 +745,59 @@ def do_check_gitlab(args, dbs): # pylint: disable=unused-argument return 0 +def find_unprocessed_commits(dbs, last_commit, source, merge_hashes): + """Find the first merge with unprocessed commits + + Walks through the merge hashes in order, looking for one that has + commits not yet tracked in the database. + + Args: + dbs (Database): Database instance + last_commit (str): Hash of the last cherry-picked commit + source (str): Source branch name + merge_hashes (list): List of merge commit hashes to check + + Returns: + NextCommitsInfo: Info about the next commits to process + """ + prev_commit = last_commit + for merge_hash in merge_hashes: + # Get all commits from prev_commit to this merge + log_output = run_git([ + 'log', '--reverse', '--format=%H|%h|%an|%s|%P', + f'{prev_commit}..{merge_hash}' + ]) + + if not log_output: + prev_commit = merge_hash + continue + + # Parse commits, filtering out those already in database + all_commits = parse_log_output(log_output, has_parents=True) + commits = [c for c in all_commits + if not dbs.commit_get(c.hash)] + + if commits: + return NextCommitsInfo(commits, True) + + # All commits in this merge are processed, skip to next + prev_commit = merge_hash + + # No merges with unprocessed commits, check remaining commits + log_output = run_git([ + 'log', '--reverse', '--format=%H|%h|%an|%s|%P', + f'{prev_commit}..{source}' + ]) + + if not log_output: + return NextCommitsInfo([], False) + + all_commits = parse_log_output(log_output, has_parents=True) + commits = [c for c in all_commits if not dbs.commit_get(c.hash)] + + return NextCommitsInfo(commits, False) + + def get_next_commits(dbs, source): """Get the next set of commits to cherry-pick from a source @@ -786,42 +839,8 @@ def get_next_commits(dbs, source): if len(parents) > 1: merge_hashes.append(parts[0]) - # Try each merge in order until we find one with unprocessed commits - prev_commit = last_commit - for merge_hash in merge_hashes: - # Get all commits from prev_commit to this merge - log_output = run_git([ - 'log', '--reverse', '--format=%H|%h|%an|%s|%P', - f'{prev_commit}..{merge_hash}' - ]) - - if not log_output: - prev_commit = merge_hash - continue - - # Parse commits, filtering out those already in database - all_commits = parse_log_output(log_output, has_parents=True) - commits = [c for c in all_commits if not dbs.commit_get(c.hash)] - - if commits: - return NextCommitsInfo(commits, True), None - - # All commits in this merge are processed, skip to next - prev_commit = merge_hash - - # No merges with unprocessed commits, check remaining commits - log_output = run_git([ - 'log', '--reverse', '--format=%H|%h|%an|%s|%P', - f'{prev_commit}..{source}' - ]) - - if not log_output: - return NextCommitsInfo([], False), None - - all_commits = parse_log_output(log_output, has_parents=True) - commits = [c for c in all_commits if not dbs.commit_get(c.hash)] - - return NextCommitsInfo(commits, False), None + return find_unprocessed_commits( + dbs, last_commit, source, merge_hashes), None def get_commits_for_pick(commit_spec):