From patchwork Wed Feb 9 19:35:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Ensure consecutive patch header lines From: Dirk Wallenstein X-Patchwork-Id: 82524 Message-Id: <20110209193505.GA11850@zap> To: Peter Maydell Cc: patchwork@lists.ozlabs.org Date: Wed, 9 Feb 2011 20:35:05 +0100 Reset the state if we can't proceed after the optional extended header line. Signed-off-by: Dirk Wallenstein --- This should do the trick -- at least for git-format-patch patches. Maybe we need a class here to be able to start over with the current line. apps/patchwork/parser.py | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/apps/patchwork/parser.py b/apps/patchwork/parser.py index 24631b7..985e196 100644 --- a/apps/patchwork/parser.py +++ b/apps/patchwork/parser.py @@ -62,6 +62,7 @@ def parse_patch(text): # line counts while parsing a patch hunk lc = (0, 0) hunk = 0 + seen_extended_header_line = False for line in text.decode('utf-8').split('\n'): line += '\n' @@ -83,6 +84,16 @@ def parse_patch(text): buf += line if line.startswith('--- '): state = 2 + seen_extended_header_line = False + + elif not seen_extended_header_line: + seen_extended_header_line = True + + else: + seen_extended_header_line = False + state = 0 + commentbuf += buf + line + buf = '' elif state == 2: if line.startswith('+++ '):