From: Sean Anderson <seanga2@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH v2 3/3] patman: Support multi-line changes in changelogs
Date: Mon, 13 Apr 2020 17:51:26 -0400 [thread overview]
Message-ID: <20200413215126.548213-4-seanga2@gmail.com> (raw)
In-Reply-To: <20200413215126.548213-1-seanga2@gmail.com>
This patch adds support to multi-line changes. That is, if one has a line
in a changelog like
- Do a thing but
it spans multiple lines
Using Series-process-log sort would sort as if those lines were unrelated.
With this patch, any change line starting with whitespace will be
considered part of the change before it.
Signed-off-by: Sean Anderson <seanga2@gmail.com>
---
Changes in v2:
- New
tools/patman/README | 10 ++++++++--
tools/patman/patchstream.py | 35 +++++++++++++++++++++++++++--------
2 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/tools/patman/README b/tools/patman/README
index ce912aacbb..433bbf1683 100644
--- a/tools/patman/README
+++ b/tools/patman/README
@@ -270,8 +270,14 @@ Patch-cc: Their Name <email>
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.
diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py
index f29ad87e70..eeac5d268e 100644
--- a/tools/patman/patchstream.py
+++ b/tools/patman/patchstream.py
@@ -45,6 +45,9 @@ re_commit = re.compile('^commit ([0-9a-f]*)$')
# 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)
@@ -72,6 +75,7 @@ class PatchStream:
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
@@ -130,6 +134,20 @@ class PatchStream:
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
@@ -170,6 +188,7 @@ class PatchStream:
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)
@@ -210,6 +229,7 @@ class PatchStream:
# 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
@@ -264,20 +284,18 @@ class PatchStream:
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
@@ -370,6 +388,7 @@ class PatchStream:
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=' %
--
2.25.1
prev parent reply other threads:[~2020-04-13 21:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-13 21:51 [PATCH v2 0/3] patman: Add changelog customization options Sean Anderson
2020-04-13 21:51 ` [PATCH v2 1/3] patman: Add option to suppress empty changelog entries Sean Anderson
2020-04-19 23:37 ` Simon Glass
2020-04-13 21:51 ` [PATCH v2 2/3] patman: Add new tags for finer-grained changelog control Sean Anderson
2020-04-13 21:51 ` Sean Anderson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200413215126.548213-4-seanga2@gmail.com \
--to=seanga2@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox