Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A9823C678D5 for ; Wed, 8 Mar 2023 18:53:53 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 096A385DD5; Wed, 8 Mar 2023 19:53:27 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="LYGGqNCN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A345E85DCA; Wed, 8 Mar 2023 19:53:20 +0100 (CET) Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 24B6C85DCA for ; Wed, 8 Mar 2023 19:53:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-pl1-x62d.google.com with SMTP id h8so18561589plf.10 for ; Wed, 08 Mar 2023 10:53:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1678301595; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=W169mu8QnWokq2RNNvUkTrfWcmQ1HdO1zjkyR0vPk+Y=; b=LYGGqNCN+Gh8yEkOp7ptsyY5YYHXSK3YMMFvP/1GLNOFWkkLI+MqLVMjsQ0u09kSkh wYHYjEj+3JJDkb1Xit9d3UiFOTm+cqDj/ahoms1gDDaOovnCHXGHYcm4+CIKAuTuOamX GAoBzCBwcuNZtoAqXKr0wjPf3YgJK+6mK5Auo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678301595; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W169mu8QnWokq2RNNvUkTrfWcmQ1HdO1zjkyR0vPk+Y=; b=1LcMnH17m0c8pF/Nhpv8U+cAybkHA4/QZfpaiMf+NTRD6WLmJA7ndklF1PLBFTwVVS 2TNyJA0hFGXMnH6OQSJfz4jLj6NDCYnecLjXfY9rTE6XCna/pFDOFritybpu/ejrrZdO eHGhLxxauVRXjg+Lx7TCd8GUduEvu61rYqzeELY08aqHZ2INcLggUCJfS2fDLPmk7soN k2J+fpyyZpyvCx9Lf8DHdUAXIHuyu2huE1X/SkmFdIWzRXWro3mKLHcj8D1hxHWwlxB7 sIVGtQ5XEhuwV5DVuFOUM2uYhaEkInxMt9sA20w0vGlosviTOj4bKi7WAjCofD5ssNoW QUaA== X-Gm-Message-State: AO0yUKUWtnPnaEMEh1mp7h7Hcme6QJmIb5XMG0dngLm8uPEMR0Vp7egl HY3a5NBX8iM2ZHMqZDGsGVNvejVNwW7iRwZpiPQ= X-Google-Smtp-Source: AK7set8IQ8vq2BB/b+WVWM7Ls9mfFcWd4xkzAlZ4fdqkMbods5eOtFZUajkndAo06RFO8X2C3Amu4w== X-Received: by 2002:a17:902:ecd2:b0:194:5c63:364c with SMTP id a18-20020a170902ecd200b001945c63364cmr24476173plh.62.1678301595319; Wed, 08 Mar 2023 10:53:15 -0800 (PST) Received: from sjg1.corp.google.com ([2620:15c:9d:200:f975:4c6:dcaf:7762]) by smtp.gmail.com with ESMTPSA id kf3-20020a17090305c300b001994fc55998sm10134198plb.217.2023.03.08.10.53.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Mar 2023 10:53:14 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Doug Anderson , Simon Glass , Maxim Cournoyer Subject: [PATCH v3 2/4] patman: Refactor MakeCcFile() into two functions Date: Wed, 8 Mar 2023 10:52:53 -0800 Message-Id: <20230308185256.120345-3-sjg@chromium.org> X-Mailer: git-send-email 2.40.0.rc0.216.gc4246ad0f0-goog In-Reply-To: <20230308185256.120345-1-sjg@chromium.org> References: <20230308185256.120345-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean This function is quite long. Moving the handling of a commit into a separate function. This will make it easier to do the work in parallel. Update function comments while we are here. Signed-off-by: Simon Glass Reviewed-by: Douglas Anderson --- Changes in v3: - Reword comment for all_skips - Sort the set directly instead of converting it to a list first Changes in v2: - Fix missing 'f' on format string tools/patmanu/series.py | 81 +++++++++++++++++++++++++++++------------ 1 file changed, 57 insertions(+), 24 deletions(-) diff --git a/tools/patmanu/series.py b/tools/patmanu/series.py index f2d415609d2..4fbcc60b797 100644 --- a/tools/patmanu/series.py +++ b/tools/patmanu/series.py @@ -234,6 +234,49 @@ class Series(dict): str = 'Change log exists, but no version is set' print(col.build(col.RED, str)) + def GetCcForCommit(self, commit, process_tags, warn_on_error, + add_maintainers, limit, get_maintainer_script, + all_skips): + """Get the email CCs to use with a particular commit + + Uses subject tags and get_maintainers.pl script to find people to cc + on a patch + + Args: + commit (Commit): Commit to process + process_tags (bool): Process tags as if they were aliases + warn_on_error (bool): True to print a warning when an alias fails to + match, False to ignore it. + add_maintainers (bool or list of str): Either: + True/False to call the get_maintainers to CC maintainers + List of maintainers to include (for testing) + limit (int): Limit the length of the Cc list (None if no limit) + get_maintainer_script (str): The file name of the get_maintainer.pl + script (or compatible). + all_skips (set of str): Updated to include the set of bouncing email + addresses that were dropped from the output. This is essentially + a return value from this function. + + Returns: + list of str: List of email addresses to cc + """ + cc = [] + if process_tags: + cc += gitutil.build_email_list(commit.tags, + warn_on_error=warn_on_error) + cc += gitutil.build_email_list(commit.cc_list, + warn_on_error=warn_on_error) + if type(add_maintainers) == type(cc): + cc += add_maintainers + elif add_maintainers: + cc += get_maintainer.get_maintainer(get_maintainer_script, + commit.patch) + all_skips |= set(cc) & set(settings.bounces) + cc = list(set(cc) - set(settings.bounces)) + if limit is not None: + cc = cc[:limit] + return cc + def MakeCcFile(self, process_tags, cover_fname, warn_on_error, add_maintainers, limit, get_maintainer_script): """Make a cc file for us to use for per-commit Cc automation @@ -241,15 +284,15 @@ class Series(dict): Also stores in self._generated_cc to make ShowActions() faster. Args: - process_tags: Process tags as if they were aliases - cover_fname: If non-None the name of the cover letter. - warn_on_error: True to print a warning when an alias fails to match, - False to ignore it. - add_maintainers: Either: + process_tags (bool): Process tags as if they were aliases + cover_fname (str): If non-None the name of the cover letter. + warn_on_error (bool): True to print a warning when an alias fails to + match, False to ignore it. + add_maintainers (bool or list of str): Either: True/False to call the get_maintainers to CC maintainers List of maintainers to include (for testing) - limit: Limit the length of the Cc list (None if no limit) - get_maintainer_script: The file name of the get_maintainer.pl + limit (int): Limit the length of the Cc list (None if no limit) + get_maintainer_script (str): The file name of the get_maintainer.pl script (or compatible). Return: Filename of temp file created @@ -259,28 +302,18 @@ class Series(dict): fname = '/tmp/patman.%d' % os.getpid() fd = open(fname, 'w', encoding='utf-8') all_ccs = [] + all_skips = set() for commit in self.commits: - cc = [] - if process_tags: - cc += gitutil.build_email_list(commit.tags, - warn_on_error=warn_on_error) - cc += gitutil.build_email_list(commit.cc_list, - warn_on_error=warn_on_error) - if type(add_maintainers) == type(cc): - cc += add_maintainers - elif add_maintainers: - - cc += get_maintainer.get_maintainer(get_maintainer_script, - commit.patch) - for x in set(cc) & set(settings.bounces): - print(col.build(col.YELLOW, 'Skipping "%s"' % x)) - cc = list(set(cc) - set(settings.bounces)) - if limit is not None: - cc = cc[:limit] + cc = self.GetCcForCommit(commit, process_tags, warn_on_error, + add_maintainers, limit, + get_maintainer_script, all_skips) all_ccs += cc print(commit.patch, '\0'.join(sorted(set(cc))), file=fd) self._generated_cc[commit.patch] = cc + for x in sorted(all_skips): + print(col.build(col.YELLOW, f'Skipping "{x}"')) + if cover_fname: cover_cc = gitutil.build_email_list(self.get('cover_cc', '')) cover_cc = list(set(cover_cc + all_ccs)) -- 2.40.0.rc0.216.gc4246ad0f0-goog