From patchwork Fri Sep 11 15:54:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Lespiau X-Patchwork-Id: 516851 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.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 13189140180 for ; Sat, 12 Sep 2015 01:56:47 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id EC2B91A2BBF for ; Sat, 12 Sep 2015 01:56:46 +1000 (AEST) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lists.ozlabs.org (Postfix) with ESMTP id B5B7A1A0795 for ; Sat, 12 Sep 2015 01:55:32 +1000 (AEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 11 Sep 2015 08:55:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,511,1437462000"; d="scan'208";a="559866912" Received: from jeffzhua-mobl.amr.corp.intel.com (HELO strange.amr.corp.intel.com) ([10.254.88.85]) by FMSMGA003.fm.intel.com with ESMTP; 11 Sep 2015 08:55:31 -0700 From: Damien Lespiau To: patchwork@lists.ozlabs.org Subject: [PATCH 06/51] parsemail: Extract building the list of mail references Date: Fri, 11 Sep 2015 16:54:39 +0100 Message-Id: <1441986924-26689-7-git-send-email-damien.lespiau@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1441986924-26689-1-git-send-email-damien.lespiau@intel.com> References: <1441986924-26689-1-git-send-email-damien.lespiau@intel.com> X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" We'll need to figure out whether the mail we are parsing is the root of the thread to automatically build series, and we'll need the list of references for that. Signed-off-by: Damien Lespiau --- patchwork/bin/parsemail.py | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/patchwork/bin/parsemail.py b/patchwork/bin/parsemail.py index 8c26c5f..a622187 100755 --- a/patchwork/bin/parsemail.py +++ b/patchwork/bin/parsemail.py @@ -162,6 +162,22 @@ class MailContent: self.patch = None self.comment = None +def build_references_list(mail): + # construct a list of possible reply message ids + refs = [] + + if 'In-Reply-To' in mail: + refs.append(mail.get('In-Reply-To')) + + if 'References' in mail: + rs = mail.get('References').split() + rs.reverse() + for r in rs: + if r not in refs: + refs.append(r) + + return refs + def parse_series_marker(subject_prefixes): """If this patch is part a of multi-patches series, ie has x/n in its subject, return (x, n). Otherwise, return (None, None).""" @@ -246,7 +262,8 @@ def find_content(project, mail): headers = mail_headers(mail)) else: - cpatch = find_patch_for_comment(project, mail) + refs = build_references_list(mail) + cpatch = find_patch_for_comment(project, refs) if not cpatch: return ret ret.comment = Comment(patch = cpatch, date = mail_date(mail), @@ -255,19 +272,7 @@ def find_content(project, mail): return ret -def find_patch_for_comment(project, mail): - # construct a list of possible reply message ids - refs = [] - if 'In-Reply-To' in mail: - refs.append(mail.get('In-Reply-To')) - - if 'References' in mail: - rs = mail.get('References').split() - rs.reverse() - for r in rs: - if r not in refs: - refs.append(r) - +def find_patch_for_comment(project, refs): for ref in refs: patch = None