From 757f64a89ba5bb04661b3f43444ca57fa6db1132 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 20 Apr 2014 10:50:13 -0600 Subject: patman: Deal with 'git apply' failures correctly This sort of failure is rare, but the code to deal with it is wrong. Fix it. Signed-off-by: Simon Glass --- tools/patman/gitutil.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py index 5dcbaa3..3ea256d 100644 --- a/tools/patman/gitutil.py +++ b/tools/patman/gitutil.py @@ -11,6 +11,7 @@ import subprocess import sys import terminal +import checkpatch import settings @@ -193,6 +194,7 @@ def ApplyPatch(verbose, fname): Args: fname: filename of patch file to apply """ + col = terminal.Color() cmd = ['git', 'am', fname] pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -203,8 +205,8 @@ def ApplyPatch(verbose, fname): print line match = re_error.match(line) if match: - print GetWarningMsg('warning', match.group(1), int(match.group(2)), - 'Patch failed') + print checkpatch.GetWarningMsg(col, 'warning', match.group(1), + int(match.group(2)), 'Patch failed') return pipe.returncode == 0, stdout def ApplyPatches(verbose, args, start_point): -- cgit v1.1 From 102061bd8b0b174e1cf811dfd35641d8a9e4eba3 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 20 Apr 2014 10:50:14 -0600 Subject: patman: Avoid duplicate sign-offs Keep track of all Signed-off-by tags in a commit and silently suppress any duplicates. Signed-off-by: Simon Glass --- tools/patman/README | 1 + tools/patman/commit.py | 14 ++++++++++++++ tools/patman/patchstream.py | 10 ++++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/patman/README b/tools/patman/README index b3aba13..5fb508b 100644 --- a/tools/patman/README +++ b/tools/patman/README @@ -192,6 +192,7 @@ END A sign-off is added automatically to your patches (this is probably a bug). If you put this tag in your patches, it will override the default signoff that patman automatically adds. + Multiple duplicate signoffs will be removed. Tested-by: Their Name Reviewed-by: Their Name diff --git a/tools/patman/commit.py b/tools/patman/commit.py index 89cce7f..3e0adb8 100644 --- a/tools/patman/commit.py +++ b/tools/patman/commit.py @@ -29,6 +29,7 @@ class Commit: self.tags = [] self.changes = {} self.cc_list = [] + self.signoff_set = set() self.notes = [] def AddChange(self, version, info): @@ -72,3 +73,16 @@ class Commit: cc_list: List of aliases or email addresses """ self.cc_list += cc_list + + def CheckDuplicateSignoff(self, signoff): + """Check a list of signoffs we have send for this patch + + Args: + signoff: Signoff line + Returns: + True if this signoff is new, False if we have already seen it. + """ + if signoff in self.signoff_set: + return False + self.signoff_set.add(signoff) + return True diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py index c4017e0..9f5682c 100644 --- a/tools/patman/patchstream.py +++ b/tools/patman/patchstream.py @@ -21,7 +21,7 @@ re_remove = re.compile('^BUG=|^TEST=|^BRANCH=|^Change-Id:|^Review URL:' re_allowed_after_test = re.compile('^Signed-off-by:') # Signoffs -re_signoff = re.compile('^Signed-off-by:') +re_signoff = re.compile('^Signed-off-by: *(.*)') # The start of the cover letter re_cover = re.compile('^Cover-letter:') @@ -159,6 +159,7 @@ class PatchStream: commit_tag_match = re_commit_tag.match(line) commit_match = re_commit.match(line) if self.is_log else None cover_cc_match = re_cover_cc.match(line) + signoff_match = re_signoff.match(line) tag_match = None if self.state == STATE_PATCH_HEADER: tag_match = re_tag.match(line) @@ -223,7 +224,7 @@ class PatchStream: if is_blank: # Blank line ends this change list self.in_change = 0 - elif line == '---' or re_signoff.match(line): + elif line == '---': self.in_change = 0 out = self.ProcessLine(line) else: @@ -272,6 +273,11 @@ class PatchStream: else: self.tags.append(line); + # Suppress duplicate signoffs + elif signoff_match: + if self.commit.CheckDuplicateSignoff(signoff_match.group(1)): + out = [line] + # Well that means this is an ordinary line else: pos = 1 -- cgit v1.1