mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-08 19:11:53 +00:00
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>
This commit is contained in:
parent
b5cc399053
commit
313ef5f897
2 changed files with 13 additions and 4 deletions
|
@ -27,6 +27,7 @@ class Commit:
|
||||||
rtags: Response tags (e.g. Reviewed-by) collected by the commit, dict:
|
rtags: Response tags (e.g. Reviewed-by) collected by the commit, dict:
|
||||||
key: rtag type (e.g. 'Reviewed-by')
|
key: rtag type (e.g. 'Reviewed-by')
|
||||||
value: Set of people who gave that rtag, each a name/email string
|
value: Set of people who gave that rtag, each a name/email string
|
||||||
|
warn: List of warnings for this commit, each a str
|
||||||
"""
|
"""
|
||||||
def __init__(self, hash):
|
def __init__(self, hash):
|
||||||
self.hash = hash
|
self.hash = hash
|
||||||
|
@ -38,6 +39,7 @@ class Commit:
|
||||||
self.notes = []
|
self.notes = []
|
||||||
self.change_id = None
|
self.change_id = None
|
||||||
self.rtags = collections.defaultdict(set)
|
self.rtags = collections.defaultdict(set)
|
||||||
|
self.warn = []
|
||||||
|
|
||||||
def AddChange(self, version, info):
|
def AddChange(self, version, info):
|
||||||
"""Add a new change line to the change list for a version.
|
"""Add a new change line to the change list for a version.
|
||||||
|
|
|
@ -68,7 +68,6 @@ class PatchStream:
|
||||||
self.skip_blank = False # True to skip a single blank line
|
self.skip_blank = False # True to skip a single blank line
|
||||||
self.found_test = False # Found a TEST= line
|
self.found_test = False # Found a TEST= line
|
||||||
self.lines_after_test = 0 # Number of lines found after TEST=
|
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.linenum = 1 # Output line number we are up to
|
||||||
self.in_section = None # Name of start...END section we are in
|
self.in_section = None # Name of start...END section we are in
|
||||||
self.notes = [] # Series notes
|
self.notes = [] # Series notes
|
||||||
|
@ -84,12 +83,20 @@ class PatchStream:
|
||||||
self.commit = None # Current commit
|
self.commit = None # Current commit
|
||||||
|
|
||||||
def _add_warn(self, warn):
|
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:
|
Args:
|
||||||
warn (str): Warning to report
|
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):
|
def _add_to_series(self, line, name, value):
|
||||||
"""Add a new Series-xxx tag.
|
"""Add a new Series-xxx tag.
|
||||||
|
@ -614,7 +621,7 @@ def fix_patch(backup_dir, fname, series, cmt):
|
||||||
if backup_dir:
|
if backup_dir:
|
||||||
shutil.copy(fname, os.path.join(backup_dir, os.path.basename(fname)))
|
shutil.copy(fname, os.path.join(backup_dir, os.path.basename(fname)))
|
||||||
shutil.move(tmpname, fname)
|
shutil.move(tmpname, fname)
|
||||||
return pst.warn
|
return cmt.warn
|
||||||
|
|
||||||
def fix_patches(series, fnames):
|
def fix_patches(series, fnames):
|
||||||
"""Fix up a list of patches identified by filenames
|
"""Fix up a list of patches identified by filenames
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue