From patchwork Thu Feb 26 20:00:12 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1943 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=1772136116; bh=GhZr1R7CIxatAg/ENX/sW5FjxWbgSk7Bvy8oT0QkjP0=; 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=doesnAZcEPdnzLdOGR7amkjtuO3cgchY0ZZU4siJEzvPtV2xUddWXP3WRBm+iy/Uv ZOCh/jxgv26fXsde0qRyS1T4sH/ehcdahIRnP1O0dZLpFb6dPK7Ue5kl3w1fepZ4Rr k+ZBn8c8MJvvhxoAserLCmio0Nb2RQwesbFlG1vjrdFw8nXDzlu8ghuY0dahSm+cjr mmeY86v3oosKCRotqqtWFc49AiKf2qGBYFBMMDxsjjadTVn6dmoNk+fVto7SjB1qrR gpT39YMIb+itr0v+DqlyZ6K9w19tbIJPeie5Av28bjJvqAp96BOSUSoKfGT0hXEMhy cz0hhwDmKtlmA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 280E169E36 for ; Thu, 26 Feb 2026 13:01:56 -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 nwJ33b7oZrDJ for ; Thu, 26 Feb 2026 13:01:56 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1772136116; bh=GhZr1R7CIxatAg/ENX/sW5FjxWbgSk7Bvy8oT0QkjP0=; 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=doesnAZcEPdnzLdOGR7amkjtuO3cgchY0ZZU4siJEzvPtV2xUddWXP3WRBm+iy/Uv ZOCh/jxgv26fXsde0qRyS1T4sH/ehcdahIRnP1O0dZLpFb6dPK7Ue5kl3w1fepZ4Rr k+ZBn8c8MJvvhxoAserLCmio0Nb2RQwesbFlG1vjrdFw8nXDzlu8ghuY0dahSm+cjr mmeY86v3oosKCRotqqtWFc49AiKf2qGBYFBMMDxsjjadTVn6dmoNk+fVto7SjB1qrR gpT39YMIb+itr0v+DqlyZ6K9w19tbIJPeie5Av28bjJvqAp96BOSUSoKfGT0hXEMhy cz0hhwDmKtlmA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0FCDE69DAB for ; Thu, 26 Feb 2026 13:01:56 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1772136113; bh=zT9wm7ghFXPWW1lOHdAUg/2I78nOa17SX+VmRtyNFOI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aXibTxe6oA5qvgpjQrlacr2dKO8zNtzqAUmJAoXAMA0dPOIlazyhYLXy9jaYfT6l/ ZmXywBrIMkzBqdknzrwbRsSQANKXQEbkSMK3Z4cYzPjvpQHFhpJ7hggk/i3ZpRhK8S SjTYEf412YDbMRyhgW3PQwS7HSapqT2/wqt6kX0dwQH2R0xH4Vj3Ino03nVysEXRI0 QZIUPcS0icdtPNwRo/gMoN1KUdWeVJrh2cUuM98S/8FwfLddmlo+qr90hhFLXua7Pr iI3r0HJKug/bKZkXGal/W1dvCCuzO834boQuMm2bZNZlAom7vVu3fJU+8opu/Yyfpo 52s0WliqQFs6Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C47BB69D79; Thu, 26 Feb 2026 13:01: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 1KaNCiuPl-n5; Thu, 26 Feb 2026 13:01:53 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1772136113; bh=BURl7ywfReA11e/aPRJlRlDrQDa1GhzJxND1xI8kC04=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nKQUdZUDfaYEzasK6HidWS+PkRGNZAcpdsSouuVQQWhZ2BeonbMCk3wws5Z7Enrf4 ici2aSm+Ot3t3qV4+TuG7aaIl6qXisMfDmJNV53Z3GdLhnGt4ouhQViHA/zLjc6CaM Wck72pajbrBnfZCsnJugjHLVeQGT2DmguAWalo0R3lbMJrYeFWg0q+FfL5BcqRx4Rg wWg+ikV+y48SThhxaEcAgQ6kjwLmfaTsHx0FtRNjFYfdFyIg7b1inBXw93BhPYUOij FZJa8KON0S4gCXxxYBD1F2vfUjmC26L3HtLVkuP2fCoOKXS84FOhVJvIB1AoeBqT4D HSUBanD2adnRQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 34B5169D4A; Thu, 26 Feb 2026 13:01:53 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 26 Feb 2026 13:00:12 -0700 Message-ID: <20260226200106.1727176-7-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260226200106.1727176-1-sjg@u-boot.org> References: <20260226200106.1727176-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ICDR55NQEEM5MESCB26FZCRIJFZTRHJ6 X-Message-ID-Hash: ICDR55NQEEM5MESCB26FZCRIJFZTRHJ6 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 06/32] patman: Auto-detect upstream for series during migration 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 When the database is upgraded to v5, try to auto-detect the upstream for each series that has a NULL upstream. This queries the git branch's remote tracking configuration and sets the upstream if a real remote (not local tracking with '.') is found. Series where auto-detection fails are still reported as a warning so the user can set them manually. Signed-off-by: Simon Glass --- tools/patman/cser_helper.py | 35 +++++++++++++++++++++++++++++++---- tools/patman/test_cseries.py | 32 ++++++++++++++++++++++---------- 2 files changed, 53 insertions(+), 14 deletions(-) diff --git a/tools/patman/cser_helper.py b/tools/patman/cser_helper.py index 0b29d52bc00..74bccfcfbc6 100644 --- a/tools/patman/cser_helper.py +++ b/tools/patman/cser_helper.py @@ -118,12 +118,39 @@ class CseriesHelper: self.db.open_it() def _check_null_upstreams(self): - """Warn about series that have no upstream set""" + """Detect and warn about series that have no upstream set + + For each series without an upstream, try to detect it from the + git branch's remote tracking configuration. Any series that + cannot be auto-detected are reported as a warning. + """ names = self.db.series_get_null_upstream() - if names: + if not names: + return + + still_null = [] + git_dir = self.gitdir or '.git' + for name in names: + remote_name = None + if gitutil.check_branch(name, git_dir=self.gitdir): + us_ref, _ = gitutil.get_upstream(git_dir, name) + if us_ref and '/' in us_ref and not us_ref.startswith( + 'refs/'): + remote_name = us_ref.split('/')[0] + if remote_name: + idnum = self.db.series_find_by_name(name) + self.db.series_set_upstream(idnum, remote_name) + tout.progress(f"Set upstream for series '{name}' to " + f"'{remote_name}'", trailer='') + else: + still_null.append(name) + + if len(still_null) < len(names): + self.db.commit() + if still_null: tout.warning( - f'{len(names)} series without an upstream:') - for name in names: + f'{len(still_null)} series without an upstream:') + for name in still_null: tout.warning(f' {name}') def close_database(self): diff --git a/tools/patman/test_cseries.py b/tools/patman/test_cseries.py index cf0d8cfdab6..23527cfa8f0 100644 --- a/tools/patman/test_cseries.py +++ b/tools/patman/test_cseries.py @@ -3367,11 +3367,20 @@ Date: .* def test_migrate_upstream_warning(self): """Test that migrating to v5 warns about series without upstream""" + self.make_git_tree() + + # Set 'first' branch to track a remote-style upstream so that + # auto-detection can find it + self.repo.config.set_multivar('branch.first.remote', '', 'origin') + self.repo.config.set_multivar('branch.first.merge', '', + 'refs/heads/main') + db = database.Database(f'{self.tmpdir}/.patman2.db') with terminal.capture(): db.open_it() - # Create a v4 database with some series + # Create a v4 database with some series; 'first' has a matching + # branch with a detectable remote, 'second' and 'third' do not with terminal.capture() as (out, _): db.migrate_to(4) self.assertEqual( @@ -3390,10 +3399,9 @@ Date: .* db.commit() db.close() - # Now open via CseriesHelper which triggers migration and check - self.make_git_tree() cser = cseries.Cseries(self.tmpdir, terminal.COLOR_NEVER) cser.topdir = self.tmpdir + cser.gitdir = self.gitdir # Point at our v4 database database.Database.instances = {} @@ -3403,18 +3411,22 @@ Date: .* old_version = cser.db.start() self.assertEqual(4, old_version) - # Set upstream on one series so only two are reported - idnum = cser.db.series_find_by_name('second') - cser.db.series_set_upstream(idnum, 'us') - cser.db.commit() - - with terminal.capture() as (_, err): + # 'first' should be auto-detected, 'second' and 'third' have no + # matching branch with a remote upstream + with terminal.capture() as (out, err): cser._check_null_upstreams() + self.assertIn("Set upstream for series 'first' to 'origin'", + out.getvalue()) lines = err.getvalue().strip().splitlines() self.assertEqual('2 series without an upstream:', lines[0]) - self.assertEqual(' first', lines[1]) + self.assertEqual(' second', lines[1]) self.assertEqual(' third', lines[2]) + # Check that 'first' was actually updated in the database + slist = cser.db.series_get_dict() + self.assertEqual('origin', slist['first'].upstream) + self.assertIsNone(slist['second'].upstream) + cser.db.close() def test_series_scan(self):