interpreted by git send-email if you use it.
Series-process-log: sort, uniq
- This tells patman to sort and/or uniq the change logs. It is
- assumed that each change log entry is only a single line long.
+ This tells patman to sort and/or uniq the change logs. Changes may be
+ multiple lines long, as long as each subsequent line of a change begins
+ with a whitespace character. For example,
+
+- This change
+ continues onto the next line
+- But this change is separate
+
Use 'sort' to sort the entries, and 'uniq' to include only
unique entries. If omitted, no change log processing is done.
Separate each tag with a comma.
# We detect these since checkpatch doesn't always do it
re_space_before_tab = re.compile('^[+].* \t')
+# Match indented lines for changes
+re_leading_whitespace = re.compile('^\s')
+
# States we can be in - can we use range() and still have comments?
STATE_MSG_HEADER = 0 # Still in the message header
STATE_PATCH_SUBJECT = 1 # In patch subject (first line of log for a commit)
self.is_log = is_log # True if indent like git log
self.in_change = None # Name of the change list we are in
self.change_version = 0 # Non-zero if we are in a change list
+ self.change_lines = [] # Lines of the current change
self.blank_count = 0 # Number of blank lines stored up
self.state = STATE_MSG_HEADER # What state are we in?
self.signoff = [] # Contents of signoff line
raise ValueError("%s: Cannot decode version info '%s'" %
(self.commit.hash, line))
+ def FinalizeChange(self):
+ """Finalize a (multi-line) change and add it to the series or commit"""
+ if not self.change_lines:
+ return
+ change = '\n'.join(self.change_lines)
+
+ if self.in_change == 'Series':
+ self.series.AddChange(self.change_version, self.commit, change)
+ elif self.in_change == 'Cover':
+ self.series.AddChange(self.change_version, None, change)
+ elif self.in_change == 'Commit':
+ self.commit.AddChange(self.change_version, change)
+ self.change_lines = []
+
def ProcessLine(self, line):
"""Process a single line of a patch file or commit log
commit_tag_match = re_commit_tag.match(line)
cover_match = re_cover.match(line)
signoff_match = re_signoff.match(line)
+ leading_whitespace_match = re_leading_whitespace.match(line)
tag_match = None
if self.state == STATE_PATCH_HEADER:
tag_match = re_tag.match(line)
# is missing, fix it up.
if self.in_change:
self.warn.append("Missing 'blank line' in section '%s-changes'" % self.in_change)
+ self.FinalizeChange()
self.in_change = None
self.change_version = 0
elif self.in_change:
if is_blank:
# Blank line ends this change list
+ self.FinalizeChange()
self.in_change = None
self.change_version = 0
elif line == '---':
+ self.FinalizeChange()
self.in_change = None
self.change_version = 0
out = self.ProcessLine(line)
- else:
- if self.is_log:
- if self.in_change == 'Series':
- self.series.AddChange(self.change_version, self.commit, line)
- elif self.in_change == 'Cover':
- self.series.AddChange(self.change_version, None, line)
- elif self.in_change == 'Commit':
- self.commit.AddChange(self.change_version, line)
+ elif self.is_log:
+ if not leading_whitespace_match:
+ self.FinalizeChange()
+ self.change_lines.append(line)
self.skip_blank = False
# Detect Series-xxx tags
def Finalize(self):
"""Close out processing of this patch stream"""
+ self.FinalizeChange()
self.CloseCommit()
if self.lines_after_test:
self.warn.append('Found %d lines after TEST=' %