From nobody Fri Oct 18 06:20:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1533197678291175.78487456477592; Thu, 2 Aug 2018 01:14:38 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8756581DE1; Thu, 2 Aug 2018 08:14:36 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 73DB72010CC6; Thu, 2 Aug 2018 08:14:36 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1BFD418037EC; Thu, 2 Aug 2018 08:14:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w728EY3M027495 for ; Thu, 2 Aug 2018 04:14:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 448DF20180EB; Thu, 2 Aug 2018 08:14:34 +0000 (UTC) Received: from lemon.usersys.redhat.com (ovpn-12-100.pek2.redhat.com [10.72.12.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF9752026D66; Thu, 2 Aug 2018 08:14:32 +0000 (UTC) From: Fam Zheng To: patchew-devel@redhat.com Date: Thu, 2 Aug 2018 16:14:20 +0800 Message-Id: <20180802081422.25982-3-famz@redhat.com> In-Reply-To: <20180802081422.25982-1-famz@redhat.com> References: <20180802081422.25982-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 2/4] tags: Improve TagsUpdate event X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 02 Aug 2018 08:14:36 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" So that the event carries old and new tags, which can help other modules to implement state transition logics. Signed-off-by: Fam Zheng --- mods/tags.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/mods/tags.py b/mods/tags.py index 5ec5bc2..01bf8a1 100644 --- a/mods/tags.py +++ b/mods/tags.py @@ -48,7 +48,8 @@ series cover letter, patch mail body and their replies. =20 def __init__(self): register_handler("MessageAdded", self.on_message_added) - declare_event("TagsUpdate", series=3D"message object that is updat= ed") + declare_event("TagsUpdate", series=3D"message object that is updat= ed", + old=3D"old tag set", new=3D"new tag set") =20 # XXX: get this list through module config? def get_tag_prefixes(self): @@ -58,9 +59,10 @@ series cover letter, patch mail body and their replies. def update_tags(self, s): old =3D s.get_property("tags", []) new =3D self.look_for_tags(s) - if set(old) !=3D set(new): - s.set_property("tags", list(set(new))) - return True + old, new =3D set(old), set(new) + if old !=3D new: + s.set_property("tags", list(new)) + return old, new =20 def on_message_added(self, event, message): series =3D message.get_series_head() @@ -75,7 +77,8 @@ series cover letter, patch mail body and their replies. elif newer_than(series, m): m.set_property("obsoleted-by", series.message_id) =20 - updated =3D self.update_tags(series) + old, new =3D self.update_tags(series) + updated =3D old !=3D new =20 for p in series.get_patches(): updated =3D updated or self.update_tags(p) @@ -101,7 +104,7 @@ series cover letter, patch mail body and their replies. series.set_property("reviewed", True) series.set_property("reviewers", list(reviewers)) if updated: - emit_event("TagsUpdate", series=3Dseries) + emit_event("TagsUpdate", series=3Dseries, old=3Dold, new=3Dnew) =20 def parse_message_tags(self, m): r =3D [] --=20 2.17.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel