From a10fd93cbc2ddf1da1f8b6d915f4bc3276ff7731 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 15 Dec 2012 10:42:04 +0000 Subject: patman: Make command methods return a CommandResult Rather than returning a list of things, return an object. That makes it easier to access the returned items, and easier to extend the return value later. Signed-off-by: Simon Glass --- tools/patman/patchstream.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools/patman/patchstream.py') diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py index f7ee75a..1e4a36f 100644 --- a/tools/patman/patchstream.py +++ b/tools/patman/patchstream.py @@ -346,7 +346,7 @@ def GetMetaData(start, count): """ pipe = [['git', 'log', '--no-color', '--reverse', 'HEAD~%d' % start, '-n%d' % count]] - stdout = command.RunPipe(pipe, capture=True) + stdout = command.RunPipe(pipe, capture=True).stdout series = Series() ps = PatchStream(series, is_log=True) for line in stdout.splitlines(): -- cgit v1.1 From e62f905e1cbe55efd7438d4ef6c5d349373f2314 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 15 Dec 2012 10:42:06 +0000 Subject: patman: Allow reading metadata from a list of commits We normally read from the current branch, but buildman will need to look at commits from another branch. Allow the metadata to be read from any list of commits, to provide this flexibility. Signed-off-by: Simon Glass --- tools/patman/patchstream.py | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'tools/patman/patchstream.py') diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py index 1e4a36f..bed921d 100644 --- a/tools/patman/patchstream.py +++ b/tools/patman/patchstream.py @@ -237,7 +237,8 @@ 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: @@ -334,26 +335,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', '--no-color', '--reverse', 'HEAD~%d' % start, - '-n%d' % count]] + 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 - series = Series() 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. -- cgit v1.1 From 28b3594eb9b6d20ffab482fe37427502536c2bb6 Mon Sep 17 00:00:00 2001 From: Doug Anderson Date: Fri, 15 Mar 2013 13:24:05 +0000 Subject: patman: Make "Reviewed-by" an important tag Although "Reviewed-by:" is a tag that gerrit adds, it's also a tag used by upstream. Stripping it is undesirable. In fact, we should treat it as important. Signed-off-by: Doug Anderson Reviewed-by: Otavio Salvador Acked-by: Simon Glass --- tools/patman/patchstream.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools/patman/patchstream.py') diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py index bed921d..91542ad 100644 --- a/tools/patman/patchstream.py +++ b/tools/patman/patchstream.py @@ -31,7 +31,7 @@ from series import Series # Tags that we detect and remove re_remove = re.compile('^BUG=|^TEST=|^BRANCH=|^Change-Id:|^Review URL:' - '|Reviewed-on:|Reviewed-by:|Commit-Ready:') + '|Reviewed-on:|Commit-Ready:') # Lines which are allowed after a TEST= line re_allowed_after_test = re.compile('^Signed-off-by:') @@ -46,7 +46,7 @@ re_cover = re.compile('^Cover-letter:') re_series = re.compile('^Series-(\w*): *(.*)') # Commit tags that we want to collect and keep -re_tag = re.compile('^(Tested-by|Acked-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 (.*)') -- cgit v1.1 From fe2f8d9e2f1bc00f143a22191a1d7076667ff436 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 20 Mar 2013 16:43:00 +0000 Subject: patman: Add Cover-letter-cc tag to Cc cover letter to people The cover letter is sent to everyone who is on the Cc list for any of the patches in the series. Sometimes it is useful to send just the cover letter to additional people, so that they are aware of the series, but don't need to wade through all the individual patches. Add a new Cover-letter-cc tag for this purpose. Signed-off-by: Simon Glass Reviewed-by: Doug Anderson --- tools/patman/patchstream.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tools/patman/patchstream.py') diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py index 91542ad..5c2d3bc 100644 --- a/tools/patman/patchstream.py +++ b/tools/patman/patchstream.py @@ -42,6 +42,9 @@ 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*): *(.*)') @@ -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: -- cgit v1.1 From 3fefd5efa664adc06ed49547e817f3e328266a15 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 3 Apr 2013 11:01:39 +0000 Subject: patman: Ignore all Gerrit Commit-* tags These tags are used by Gerrit, so let's ignore all of them. Signed-off-by: Simon Glass Reviewed-by: Doug Anderson --- tools/patman/patchstream.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools/patman/patchstream.py') diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py index 5c2d3bc..4fda852 100644 --- a/tools/patman/patchstream.py +++ b/tools/patman/patchstream.py @@ -31,7 +31,7 @@ from series import Series # Tags that we detect and remove re_remove = re.compile('^BUG=|^TEST=|^BRANCH=|^Change-Id:|^Review URL:' - '|Reviewed-on:|Commit-Ready:') + '|Reviewed-on:|Commit-\w*:') # Lines which are allowed after a TEST= line re_allowed_after_test = re.compile('^Signed-off-by:') -- cgit v1.1 From 68618281e5090f875a8fa5fee3b2b3a0239d8190 Mon Sep 17 00:00:00 2001 From: Doug Anderson Date: Fri, 1 Mar 2013 11:11:07 +0000 Subject: patman: Don't barf if the word 'commit' starts a line Patman's regular expression for detecting the start of a commit in a git log was a little simplistic and could be confused if the git log itself had the word "commit" as the start of a line (as this commit does). Make patman a little more robust. Signed-off-by: Doug Anderson Acked-by: Simon Glass --- tools/patman/patchstream.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools/patman/patchstream.py') diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py index 4fda852..fc7492e 100644 --- a/tools/patman/patchstream.py +++ b/tools/patman/patchstream.py @@ -52,7 +52,7 @@ re_series = re.compile('^Series-(\w*): *(.*)') 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') -- cgit v1.1 From 645b271a6039e79b368f027a5624dc0820441733 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 26 Mar 2013 13:09:44 +0000 Subject: patman: Add Series-process-log tag to sort/uniq change logs For some series with lots of changes it is annoying that duplicate change log items are not caught. It is also helpful sometimes to sort the change logs. Add a Series-process-log tag to enable this, which can be placed in a commit to control this. The change to the Cc: line is to fix a checkpatch warning. Signed-off-by: Simon Glass Reviewed-by: Doug Anderson --- tools/patman/patchstream.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools/patman/patchstream.py') diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py index fc7492e..7334ed3 100644 --- a/tools/patman/patchstream.py +++ b/tools/patman/patchstream.py @@ -46,7 +46,7 @@ re_cover = re.compile('^Cover-letter:') 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|Reviewed-by|Cc): (.*)') -- cgit v1.1