From patchwork Wed Dec 17 02:25:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 931 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=1765938414; bh=k0T7Bcw8PlzP4fMocgRsfBzkkF94ti3Iq3jOIs1skdM=; 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=n75tKzsDuQTNih5H5PwvOCvcIeXFvHA5boIuKvd7U0nBo+p67gnbNmSEWd918Skh5 5aH/7weS2YlJGRKmsFzkZCQBgvNQ2c+6XCybtPJGhRFPIOrpwKI3Pi02JeSSG5ig7l c/POEXNTEtnz27kJrID1YEeFp0i/7eMdVYwwcMnOUVExYkTfUSCPdpHELKCQNsTfz8 oB3eKO/UNyfNAjb0MpC/YBv1gVS5A4BCOixpycQyNa2s/RQBi+Ij6FrP66Ghx3qdgF hLyIFOS2bcvdu9CML4Y5CJ+j8F/AnMk9JRUiwSir/uW2YUGE3YFRew2VUOcmLHIo44 tqQlVcH96Schg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C14B268BAB for ; Tue, 16 Dec 2025 19:26:54 -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 e1E_tmlmgoqk for ; Tue, 16 Dec 2025 19:26:54 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765938414; bh=k0T7Bcw8PlzP4fMocgRsfBzkkF94ti3Iq3jOIs1skdM=; 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=n75tKzsDuQTNih5H5PwvOCvcIeXFvHA5boIuKvd7U0nBo+p67gnbNmSEWd918Skh5 5aH/7weS2YlJGRKmsFzkZCQBgvNQ2c+6XCybtPJGhRFPIOrpwKI3Pi02JeSSG5ig7l c/POEXNTEtnz27kJrID1YEeFp0i/7eMdVYwwcMnOUVExYkTfUSCPdpHELKCQNsTfz8 oB3eKO/UNyfNAjb0MpC/YBv1gVS5A4BCOixpycQyNa2s/RQBi+Ij6FrP66Ghx3qdgF hLyIFOS2bcvdu9CML4Y5CJ+j8F/AnMk9JRUiwSir/uW2YUGE3YFRew2VUOcmLHIo44 tqQlVcH96Schg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id ACCD368BA3 for ; Tue, 16 Dec 2025 19:26:54 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765938413; bh=z0fuyvJzKv5aRykcQF+ysNqxsjY6fuu21gt05km5CDM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uzcw73wBRfCka8x3gTdqEdkJxtb/uF001vbRtGYIYEIEzXGoZmuXqn7+VtFhUMAnu FgLo5R7TFroiZ/DovygB+oXLO7NZipVGgolPKDdo/kbkAvhpxxgaBzX9ai5ngkgTnr 0lvwJK4uBa7ns83SGlSfTMVJuQuwxRgdE3jqdISNmc/dDicCi4WvcMm2q7DhyKR/aW 9qi+i3EF0ClRUC/AHGICEKo3mdudwBEwYrKGCOrclsMQ1TDhCSF5V1VnT0gNKdfNeS nuqlTl+/LLk1OnLB3OlO8guvHTVRhYleAkxIFyFQdIKW8GXEcBzdFv1V03Be3/NAla cGT3euIasZ14g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B0F0368ABD; Tue, 16 Dec 2025 19:26:53 -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 NcQR0RRyyFyz; Tue, 16 Dec 2025 19:26:53 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765938408; bh=NkxbZHXM1HIkUAzX0SrjUKUSKplvonmeEzwI3ROTovo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NmIIB7Hu1Cmb49LxufRaB4RCWB1hmwh6lEDTPS+yz+FxfOpM/8o1XTTJE0zuysZVU 0SKt24P/RuaLMgA+K2hS/9KXlgKaSa4BciCNr0p1TzKnj8nFJ2x1g9uaiglDhHPLwo qFbZJzbVShyOwnCJmQfbN0OCdW3/o5WPtU0NdT+0i4296ofEDuvf+pcaafxsIcRccM zI9vuuJYDQdEdp/Boc0haZ5dWkUQX0Vw14lpQ/tnwVs+oBesJvN+U2YPPt2ze1b/Eo uH8tLM0kWzd+x9QSjxAwP52YJVa7c6PX8mynZUhEsgvS1qrBNolqFqUPRfKBj9ugDB Tt9MEV1T3jsHw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D03486892F; Tue, 16 Dec 2025 19:26:47 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 16 Dec 2025 19:25:53 -0700 Message-ID: <20251217022611.389379-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251217022611.389379-1-sjg@u-boot.org> References: <20251217022611.389379-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: XAATIPGWEZA3FE7DBUEGFOYC3QKGWVOG X-Message-ID-Hash: XAATIPGWEZA3FE7DBUEGFOYC3QKGWVOG 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: Heinrich Schuchardt , Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 05/17] pickman: Add list-sources command 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 Add a command to list all tracked source branches and their last cherry-picked commits from the database. Usage: ./tools/pickman/pickman list-sources Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- tools/pickman/README.rst | 4 +++ tools/pickman/__main__.py | 1 + tools/pickman/control.py | 23 +++++++++++++ tools/pickman/database.py | 9 +++++ tools/pickman/ftest.py | 70 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 107 insertions(+) diff --git a/tools/pickman/README.rst b/tools/pickman/README.rst index aab0642d374..70f53a6e212 100644 --- a/tools/pickman/README.rst +++ b/tools/pickman/README.rst @@ -19,6 +19,10 @@ This finds the merge-base commit between the master branch (ci/master) and the source branch, and stores it in the database as the starting point for cherry-picking. +To list all tracked source branches:: + + ./tools/pickman/pickman list-sources + To compare branches and show commits that need to be cherry-picked:: ./tools/pickman/pickman compare diff --git a/tools/pickman/__main__.py b/tools/pickman/__main__.py index 7263f4c5fb0..63930953ebb 100755 --- a/tools/pickman/__main__.py +++ b/tools/pickman/__main__.py @@ -35,6 +35,7 @@ def parse_args(argv): add_source.add_argument('source', help='Source branch name') subparsers.add_parser('compare', help='Compare branches') + subparsers.add_parser('list-sources', help='List tracked source branches') subparsers.add_parser('test', help='Run tests') return parser.parse_args(argv) diff --git a/tools/pickman/control.py b/tools/pickman/control.py index fa53a26b6ad..5780703bfba 100644 --- a/tools/pickman/control.py +++ b/tools/pickman/control.py @@ -92,6 +92,28 @@ def do_add_source(args, dbs): return 0 +def do_list_sources(args, dbs): # pylint: disable=unused-argument + """List all tracked source branches + + Args: + args (Namespace): Parsed arguments + dbs (Database): Database instance + + Returns: + int: 0 on success + """ + sources = dbs.source_get_all() + + if not sources: + tout.info('No source branches tracked') + else: + tout.info('Tracked source branches:') + for name, last_commit in sources: + tout.info(f' {name}: {last_commit[:12]}') + + return 0 + + def do_compare(args, dbs): # pylint: disable=unused-argument """Compare branches and print results. @@ -133,6 +155,7 @@ def do_test(args, dbs): # pylint: disable=unused-argument COMMANDS = { 'add-source': do_add_source, 'compare': do_compare, + 'list-sources': do_list_sources, 'test': do_test, } diff --git a/tools/pickman/database.py b/tools/pickman/database.py index 436734fe1f7..46b8556945e 100644 --- a/tools/pickman/database.py +++ b/tools/pickman/database.py @@ -178,6 +178,15 @@ class Database: return rec[0] return None + def source_get_all(self): + """Get all source branches and their last commits + + Return: + list of tuple: (name, last_commit) pairs + """ + res = self.execute('SELECT name, last_commit FROM source ORDER BY name') + return res.fetchall() + def source_set(self, name, commit): """Set the last cherry-picked commit for a source branch diff --git a/tools/pickman/ftest.py b/tools/pickman/ftest.py index 632cd56793f..91a003b649c 100644 --- a/tools/pickman/ftest.py +++ b/tools/pickman/ftest.py @@ -287,6 +287,76 @@ class TestDatabase(unittest.TestCase): self.assertIs(dbs1, dbs2) dbs1.close() + def test_source_get_all(self): + """Test getting all sources.""" + with terminal.capture(): + dbs = database.Database(self.db_path) + dbs.start() + + # Empty initially + self.assertEqual(dbs.source_get_all(), []) + + # Add some sources + dbs.source_set('branch-a', 'abc123') + dbs.source_set('branch-b', 'def456') + dbs.commit() + + # Should be sorted by name + sources = dbs.source_get_all() + self.assertEqual(len(sources), 2) + self.assertEqual(sources[0], ('branch-a', 'abc123')) + self.assertEqual(sources[1], ('branch-b', 'def456')) + dbs.close() + + +class TestListSources(unittest.TestCase): + """Tests for list-sources command.""" + + def setUp(self): + """Set up test fixtures.""" + fd, self.db_path = tempfile.mkstemp(suffix='.db') + os.close(fd) + os.unlink(self.db_path) + self.old_db_fname = control.DB_FNAME + control.DB_FNAME = self.db_path + database.Database.instances.clear() + + def tearDown(self): + """Clean up test fixtures.""" + control.DB_FNAME = self.old_db_fname + if os.path.exists(self.db_path): + os.unlink(self.db_path) + database.Database.instances.clear() + + def test_list_sources_empty(self): + """Test list-sources with no sources""" + args = argparse.Namespace(cmd='list-sources') + with terminal.capture() as (stdout, _): + ret = control.do_pickman(args) + self.assertEqual(ret, 0) + self.assertIn('No source branches tracked', stdout.getvalue()) + + def test_list_sources(self): + """Test list-sources with sources""" + # Add some sources first + with terminal.capture(): + dbs = database.Database(self.db_path) + dbs.start() + dbs.source_set('us/next', 'abc123def456') + dbs.source_set('other/branch', 'def456abc789') + dbs.commit() + dbs.close() + + database.Database.instances.clear() + args = argparse.Namespace(cmd='list-sources') + with terminal.capture() as (stdout, _): + ret = control.do_pickman(args) + self.assertEqual(ret, 0) + output = stdout.getvalue() + self.assertIn('Tracked source branches:', output) + self.assertIn('other/branch: def456abc789', output) + self.assertIn('us/next: abc123def456', output) + if __name__ == '__main__': unittest.main()