From patchwork Wed Feb 9 19:35:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dirk Wallenstein X-Patchwork-Id: 82524 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id A0362B7101 for ; Thu, 10 Feb 2011 06:35:20 +1100 (EST) Received: from mailout02.t-online.de (mailout02.t-online.de [194.25.134.17]) by ozlabs.org (Postfix) with ESMTP id 221DCB70A9 for ; Thu, 10 Feb 2011 06:35:16 +1100 (EST) Received: from fwd01.aul.t-online.de (fwd01.aul.t-online.de ) by mailout02.t-online.de with smtp id 1PnFop-0005iW-Cj; Wed, 09 Feb 2011 20:35:15 +0100 Received: from localhost (rCR60yZSoh-txDDSOtowlDIfIr7SS7bVn-YCMb-rGhtRSsIVC8ZGc4olfPYJqLNZ-p@[84.139.58.191]) by fwd01.t-online.de with esmtp id 1PnFof-219j7I0; Wed, 9 Feb 2011 20:35:05 +0100 Date: Wed, 9 Feb 2011 20:35:05 +0100 From: Dirk Wallenstein To: Peter Maydell Subject: [PATCH] Ensure consecutive patch header lines Message-ID: <20110209193505.GA11850@zap> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-ID: rCR60yZSoh-txDDSOtowlDIfIr7SS7bVn-YCMb-rGhtRSsIVC8ZGc4olfPYJqLNZ-p X-TOI-MSGID: 3b417003-a196-4b4c-8c2d-7678aa2a4147 Cc: patchwork@lists.ozlabs.org X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org 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('+++ '):