aboutsummaryrefslogtreecommitdiff
path: root/tools/patman/patchstream.py
diff options
context:
space:
mode:
authorSimon Glass2020-10-29 21:46:24 -0600
committerSimon Glass2020-11-05 09:11:31 -0700
commit313ef5f897f15bc7ec2ca8054f4e4871a2f6be93 (patch)
treebe3546d33bf076ab8363d1e073a38c3dd97eb484 /tools/patman/patchstream.py
parentb5cc39905343312d1b7064ede72561394049be21 (diff)
patman: Attach warnings to individual patches
At present warnings are produced across the whole set of patches when parsing them. It is more useful to associate each warning with the patch (or commit) that generated it. Attach warnings to the Commit object and move them out of PatchStream. Also avoid generating duplicate warnings for the same commit. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/patman/patchstream.py')
-rw-r--r--tools/patman/patchstream.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py
index 9f283470bc2..880d7ddc7f2 100644
--- a/tools/patman/patchstream.py
+++ b/tools/patman/patchstream.py
@@ -68,7 +68,6 @@ class PatchStream:
self.skip_blank = False # True to skip a single blank line
self.found_test = False # Found a TEST= line
self.lines_after_test = 0 # Number of lines found after TEST=
- self.warn = [] # List of warnings we have collected
self.linenum = 1 # Output line number we are up to
self.in_section = None # Name of start...END section we are in
self.notes = [] # Series notes
@@ -84,12 +83,20 @@ class PatchStream:
self.commit = None # Current commit
def _add_warn(self, warn):
- """Add a new warning to report to the user
+ """Add a new warning to report to the user about the current commit
+
+ The new warning is added to the current commit if not already present.
Args:
warn (str): Warning to report
+
+ Raises:
+ ValueError: Warning is generated with no commit associated
"""
- self.warn.append(warn)
+ if not self.commit:
+ raise ValueError('Warning outside commit: %s' % warn)
+ if warn not in self.commit.warn:
+ self.commit.warn.append(warn)
def _add_to_series(self, line, name, value):
"""Add a new Series-xxx tag.
@@ -614,7 +621,7 @@ def fix_patch(backup_dir, fname, series, cmt):
if backup_dir:
shutil.copy(fname, os.path.join(backup_dir, os.path.basename(fname)))
shutil.move(tmpname, fname)
- return pst.warn
+ return cmt.warn
def fix_patches(series, fnames):
"""Fix up a list of patches identified by filenames