X-Git-Url: https://git.kernelconcepts.de/?p=karo-tx-uboot.git;a=blobdiff_plain;f=tools%2Fpatman%2Fpatchstream.py;h=7334ed30e36da32490f2fae2fe943b8f16238081;hp=3de32d582ca06ff7a1f6710d1cda671f096eaf34;hb=645b271a6039e79b368f027a5624dc0820441733;hpb=a8840cb2f040b8aa1c870b7431ce27e9ec81284e diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py index 3de32d582c..7334ed30e3 100644 --- a/tools/patman/patchstream.py +++ b/tools/patman/patchstream.py @@ -30,8 +30,8 @@ import gitutil from series import Series # Tags that we detect and remove -re_remove = re.compile('^BUG=|^TEST=|^Change-Id:|^Review URL:' - '|Reviewed-on:|Reviewed-by:') +re_remove = re.compile('^BUG=|^TEST=|^BRANCH=|^Change-Id:|^Review URL:' + '|Reviewed-on:|Commit-\w*:') # Lines which are allowed after a TEST= line re_allowed_after_test = re.compile('^Signed-off-by:') @@ -42,14 +42,17 @@ re_signoff = re.compile('^Signed-off-by:') # The start of the cover letter re_cover = re.compile('^Cover-letter:') +# A cover letter Cc +re_cover_cc = re.compile('^Cover-letter-cc: *(.*)') + # Patch series tag -re_series = re.compile('^Series-(\w*): *(.*)') +re_series = re.compile('^Series-([a-z-]*): *(.*)') # Commit tags that we want to collect and keep -re_tag = re.compile('^(Tested-by|Acked-by|Signed-off-by|Cc): (.*)') +re_tag = re.compile('^(Tested-by|Acked-by|Reviewed-by|Cc): (.*)') # The start of a new commit in the git log -re_commit = re.compile('^commit (.*)') +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') @@ -153,6 +156,7 @@ class PatchStream: # Handle state transition and skipping blank lines series_match = re_series.match(line) commit_match = re_commit.match(line) if self.is_log else None + cover_cc_match = re_cover_cc.match(line) tag_match = None if self.state == STATE_PATCH_HEADER: tag_match = re_tag.match(line) @@ -205,6 +209,10 @@ class PatchStream: self.in_section = 'cover' self.skip_blank = False + elif cover_cc_match: + value = cover_cc_match.group(1) + self.AddToSeries(line, 'cover-cc', value) + # If we are in a change list, key collected lines until a blank one elif self.in_change: if is_blank: @@ -237,19 +245,13 @@ class PatchStream: # Detect the start of a new commit elif commit_match: self.CloseCommit() - self.commit = commit.Commit(commit_match.group(1)[:7]) + # TODO: We should store the whole hash, and just display a subset + self.commit = commit.Commit(commit_match.group(1)[:8]) # Detect tags in the commit message elif tag_match: - # Onlly allow a single signoff tag - if tag_match.group(1) == 'Signed-off-by': - if self.signoff: - self.warn.append('Patch has more than one Signed-off-by ' - 'tag') - self.signoff += [line] - # Remove Tested-by self, since few will take much notice - elif (tag_match.group(1) == 'Tested-by' and + if (tag_match.group(1) == 'Tested-by' and tag_match.group(2).find(os.getenv('USER') + '@') != -1): self.warn.append("Ignoring %s" % line) elif tag_match.group(1) == 'Cc': @@ -288,8 +290,6 @@ class PatchStream: # Output the tags (signeoff first), then change list out = [] - if self.signoff: - out += self.signoff log = self.series.MakeChangeLog(self.commit) out += self.FormatTags(self.tags) out += [line] + log @@ -343,25 +343,47 @@ class PatchStream: self.Finalize() -def GetMetaData(start, count): +def GetMetaDataForList(commit_range, git_dir=None, count=None, + series = Series()): """Reads out patch series metadata from the commits This does a 'git log' on the relevant commits and pulls out the tags we are interested in. Args: - start: Commit to start from: 0=HEAD, 1=next one, etc. - count: Number of commits to list + commit_range: Range of commits to count (e.g. 'HEAD..base') + git_dir: Path to git repositiory (None to use default) + count: Number of commits to list, or None for no limit + series: Series object to add information into. By default a new series + is started. + Returns: + A Series object containing information about the commits. """ - pipe = [['git', 'log', '--reverse', 'HEAD~%d' % start, '-n%d' % count]] - stdout = command.RunPipe(pipe, capture=True) - series = Series() + params = ['git', 'log', '--no-color', '--reverse', commit_range] + if count is not None: + params[2:2] = ['-n%d' % count] + if git_dir: + params[1:1] = ['--git-dir', git_dir] + pipe = [params] + stdout = command.RunPipe(pipe, capture=True).stdout ps = PatchStream(series, is_log=True) for line in stdout.splitlines(): ps.ProcessLine(line) ps.Finalize() return series +def GetMetaData(start, count): + """Reads out patch series metadata from the commits + + This does a 'git log' on the relevant commits and pulls out the tags we + are interested in. + + Args: + start: Commit to start from: 0=HEAD, 1=next one, etc. + count: Number of commits to list + """ + return GetMetaDataForList('HEAD~%d' % start, None, count) + def FixPatch(backup_dir, fname, series, commit): """Fix up a patch file, by adding/removing as required.