From patchwork Tue Jun 4 15:56:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 1109993 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45JGl12S3sz9s4Y for ; Wed, 5 Jun 2019 01:57:01 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="jSNId7lw"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 45JGl06CnVzDqTm for ; Wed, 5 Jun 2019 01:57:00 +1000 (AEST) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2a00:1450:4864:20::534; helo=mail-ed1-x534.google.com; envelope-from=petr.vorel@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="jSNId7lw"; dkim-atps=neutral Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 45JGkr1rVQzDqSV for ; Wed, 5 Jun 2019 01:56:51 +1000 (AEST) Received: by mail-ed1-x534.google.com with SMTP id a8so1171454edx.3 for ; Tue, 04 Jun 2019 08:56:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=kxv+8sR48zyMv/ZzrMkoy+L2FBqT0A7XMMIiFvzVu/s=; b=jSNId7lwQpmKrKgN1r+OTDdEL3VZiKkqkouVaLcxzu2c+AMAaU2XJ6ADXxg6Qeg+2T WMpqMJxARz/5+f3PiPuID3Ttpah7B/scnX9F0Q7tqganhoXC2wqzA37BbSnqLiztFCij fH7wRpM86lEOR6PneWJ4jyp7GqhRpRR+5o3QHmK8GyPV7bWcr1A/6x/qWUYY/KkHlRcK iYRxAPHcaQSfOxACj+NVDfXHM/qoJvFJKkmhJriz9gkSTwkNjGRmpfKq4Zw8NEYYpPXA i1sw65VgI3zDJvVacz7zbFS9LEjo21d+jnFaYsvBAAnipJLe+166pqV5dT1enKkiqrTN RwlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=kxv+8sR48zyMv/ZzrMkoy+L2FBqT0A7XMMIiFvzVu/s=; b=DdbrIpJJuQyPovCtw2NiPrCcLMN+q4rBNgrsendOL9601ou7hpVImeJV05Lgrfc8zc UV2G1TJ5ky/3ysHD9KddbtjHUNZJj03HyOMZaLaNHiCv+Bw4q9qgy0pjxAukEQTheGPK ImYgniDu+OqLnIjCZwOewJhx8Zs3SoJmkHVjOb4L0xXN59msRolPZtg6NknvAf7euAAZ 2mMPyUqmy0RpfNSEAMlSTKtlboQLFIXlVXWhTenOMz024OA4jmIxXB2Rz6pQwwOe6Tjc wDyuI3TYCWS3jYFu92z3kgx9L3Q2RRzRyr7P8muG/X+gC4Pb+MnmNbpVtmQhgeGBuMtN V8Vg== X-Gm-Message-State: APjAAAXuMNFvkmNSCb7zMVVtPPUnDP/a1Ccw1MljS04ChC0coB1pul0t vXAK7j2E+YFn6TTehBUXap74AVIr X-Google-Smtp-Source: APXvYqxcgwoK9s43Xh+mIALBlcET66fqIaKNeZ5ApuxNkHQWIxOJ9r+zVGfp4STNbJoUSC9FCxjJdw== X-Received: by 2002:a50:ee89:: with SMTP id f9mr8890068edr.293.1559663805783; Tue, 04 Jun 2019 08:56:45 -0700 (PDT) Received: from dell5510.suse.cz ([62.201.25.198]) by smtp.gmail.com with ESMTPSA id e19sm2649156edy.36.2019.06.04.08.56.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jun 2019 08:56:44 -0700 (PDT) From: Petr Vorel To: patchwork@lists.ozlabs.org Subject: [PATCH 1/1] parser: Remove duplicity Date: Tue, 4 Jun 2019 17:56:39 +0200 Message-Id: <20190604155639.10934-1-petr.vorel@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" commit fc1d750 copied lines added in 753e457. Make sense to define it on single place (DRY). Signed-off-by: Petr Vorel --- patchwork/parser.py | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/patchwork/parser.py b/patchwork/parser.py index 7d7b571..2cd7f6f 100644 --- a/patchwork/parser.py +++ b/patchwork/parser.py @@ -37,6 +37,16 @@ list_id_headers = ['List-ID', 'X-Mailing-List', 'X-list'] SERIES_DELAY_INTERVAL = 10 +# @see https://git-scm.com/docs/git-diff#_generating_patches_with_p +EXTENDED_HEADER_LINES = ('old mode ', 'new mode ', + 'deleted file mode ', + 'new file mode ', + 'copy from ', 'copy to ', + 'rename from ', 'rename to ', + 'similarity index ', + 'dissimilarity index ', + 'new file mode ', 'index ') + logger = logging.getLogger(__name__) @@ -780,17 +790,7 @@ def parse_patch(content): buf += line if line.startswith('--- '): state = 2 - - # extended header lines - # @see https://git-scm.com/docs/git-diff#_generating_patches_with_p - if line.startswith(('old mode ', 'new mode ', - 'deleted file mode ', - 'new file mode ', - 'copy from ', 'copy to ', - 'rename from ', 'rename to ', - 'similarity index ', - 'dissimilarity index ', - 'new file mode ', 'index ')): + if line.startswith(EXTENDED_HEADER_LINES): state = 6 elif state == 2: if line.startswith('+++ '): @@ -851,16 +851,7 @@ def parse_patch(content): else: state = 5 elif state == 6: - # extended header lines - # @see https://git-scm.com/docs/git-diff#_generating_patches_with_p - if line.startswith(('old mode ', 'new mode ', - 'deleted file mode ', - 'new file mode ', - 'copy from ', 'copy to ', - 'rename from ', 'rename to ', - 'similarity index ', - 'dissimilarity index ', - 'new file mode ', 'index ')): + if line.startswith(EXTENDED_HEADER_LINES): patchbuf += buf + line buf = '' elif line.startswith('--- '):