From patchwork Mon Oct 26 01:04:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1387371 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=ANnzeaPy; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CKGsm2xGQz9sTD for ; Mon, 26 Oct 2020 12:07:55 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5A1A7824EE; Mon, 26 Oct 2020 02:05:37 +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="ANnzeaPy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4BC05824B8; Mon, 26 Oct 2020 02:05:18 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) (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 0F4B98248B for ; Mon, 26 Oct 2020 02:05:15 +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-io1-xd2f.google.com with SMTP id y20so8383776iod.5 for ; Sun, 25 Oct 2020 18:05:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Gu7CBvY3/L8TY27+EJcXvdtS+KqaWZ8WFg5nIHbV3pM=; b=ANnzeaPyAM66VaGxWh1SctXqFL3RJBZRJ6ZpKtp06mOMh70H3XRkviCn4vK/xCgsEN ShkGevSPA2lgcKnWONasEAVinRyqw79hi/1Pk0o7/SDD/pys4ipOCvE233z4e5+mE2jh k8Nywuy3kOdyZ7bsKvkV8ciIRDM93njkDoyy0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Gu7CBvY3/L8TY27+EJcXvdtS+KqaWZ8WFg5nIHbV3pM=; b=rhmDL5Ir8ZDg9zc0aOtmG5KDm0PMbyNwbTWFfW+4H9BI2Pvv575IX32VMDwhBbf0Un qxQDCzXsS146XxHjnwvEKAi8CKAjV4K3AgakWI09RqYlwbefqKnjnQ7QWBuILRkcr0pZ UmUavEmxJq5exEOpLEs9fwR5gxdP8icfl6u9mvAwk/9/hdsB3I7Ljud8pON1K8hG+baK E8ytqGuE847o0wNl1kn7FcfQPygD7s8n0sY3n7Va5vukucw31PQMlSDwemDdgB4ruE7n 9yKkaJWQAYw2U/qrGa6rbYJ8NVTSETZFveVbcb1WDoAnXSIPvXWvOGKcbZqtgOY+o5Qu d3Jw== X-Gm-Message-State: AOAM533bjWi5baHvCjqnmmSBCwvuCvUJqqdWQbKHJclZbhCfX2iY/DxI 0hA0MHT1VTpR0o8MeXp2wFKS7wlUg8Crf+Dg X-Google-Smtp-Source: ABdhPJwI9MQ2RQmjBNU19NXkeavQo5dORhCrDeFp/SuXdBFAxr8BHItlaxGRizN31ENmAoEpJyt79A== X-Received: by 2002:a02:b113:: with SMTP id r19mr5771142jah.106.1603674313751; Sun, 25 Oct 2020 18:05:13 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id a6sm5231162ili.11.2020.10.25.18.05.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Oct 2020 18:05:13 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Doug Anderson , patchwork@lists.ozlabs.org, Simon Glass Subject: [PATCH v2 14/30] patman: Move warning collection to a function Date: Sun, 25 Oct 2020 19:04:26 -0600 Message-Id: <20201026010442.1606893-15-sjg@chromium.org> X-Mailer: git-send-email 2.29.0.rc2.309.g374f81d7ae-goog In-Reply-To: <20201026010442.1606893-1-sjg@chromium.org> References: <20201026010442.1606893-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean Add a new function in PatchStream to collect the warnings generated while parsing the stream. This will allow us to adjust the logic, such as dealing with per-commit warnings. Two of the warnings are in fact internal errors, so change them to raise and exception. Signed-off-by: Simon Glass --- (no changes since v1) tools/patman/patchstream.py | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py index b2cb2debeee..9f283470bc2 100644 --- a/tools/patman/patchstream.py +++ b/tools/patman/patchstream.py @@ -83,6 +83,14 @@ class PatchStream: self.signoff = [] # Contents of signoff line self.commit = None # Current commit + def _add_warn(self, warn): + """Add a new warning to report to the user + + Args: + warn (str): Warning to report + """ + self.warn.append(warn) + def _add_to_series(self, line, name, value): """Add a new Series-xxx tag. @@ -237,7 +245,7 @@ class PatchStream: # but we are already in a section, this means 'END' is missing # for that section, fix it up. if self.in_section: - self.warn.append("Missing 'END' in section '%s'" % self.in_section) + self._add_warn("Missing 'END' in section '%s'" % self.in_section) if self.in_section == 'cover': self.series.cover = self.section elif self.in_section == 'notes': @@ -247,14 +255,16 @@ class PatchStream: if self.is_log: self.commit.notes += self.section else: - self.warn.append("Unknown section '%s'" % self.in_section) + # This should not happen + raise ValueError("Unknown section '%s'" % self.in_section) self.in_section = None self.skip_blank = True self.section = [] # but we are already in a change list, that means a blank line # is missing, fix it up. if self.in_change: - self.warn.append("Missing 'blank line' in section '%s-changes'" % self.in_change) + self._add_warn("Missing 'blank line' in section '%s-changes'" % + self.in_change) self._finalise_change() self.in_change = None self.change_version = 0 @@ -271,7 +281,8 @@ class PatchStream: if self.is_log: self.commit.notes += self.section else: - self.warn.append("Unknown section '%s'" % self.in_section) + # This should not happen + raise ValueError("Unknown section '%s'" % self.in_section) self.in_section = None self.skip_blank = True self.section = [] @@ -362,8 +373,8 @@ class PatchStream: self.in_change = 'Commit' self.change_version = self._parse_version(value, line) else: - self.warn.append('Line %d: Ignoring Commit-%s' % - (self.linenum, name)) + self._add_warn('Line %d: Ignoring Commit-%s' % + (self.linenum, name)) # Detect the start of a new commit elif commit_match: @@ -377,7 +388,7 @@ class PatchStream: # Remove Tested-by self, since few will take much notice if (rtag_type == 'Tested-by' and who.find(os.getenv('USER') + '@') != -1): - self.warn.append("Ignoring %s" % line) + self._add_warn("Ignoring %s" % line) elif rtag_type == 'Patch-cc': self.commit.AddCc(who.split(',')) else: @@ -394,8 +405,8 @@ class PatchStream: # Look for space before tab mat = RE_SPACE_BEFORE_TAB.match(line) if mat: - self.warn.append('Line %d/%d has space before tab' % - (self.linenum, mat.start())) + self._add_warn('Line %d/%d has space before tab' % + (self.linenum, mat.start())) # OK, we have a valid non-blank line out = [line] @@ -427,8 +438,7 @@ class PatchStream: self._finalise_change() self._close_commit() if self.lines_after_test: - self.warn.append('Found %d lines after TEST=' % - self.lines_after_test) + self._add_warn('Found %d lines after TEST=' % self.lines_after_test) def _write_message_id(self, outfd): """Write the Message-Id into the output. @@ -503,8 +513,8 @@ class PatchStream: self.blank_count += 1 else: if self.blank_count and (line == '-- ' or match): - self.warn.append("Found possible blank line(s) at " - "end of file '%s'" % last_fname) + self._add_warn("Found possible blank line(s) at end of file '%s'" % + last_fname) outfd.write('+\n' * self.blank_count) outfd.write(line + '\n') self.blank_count = 0