From nobody Sat Apr 20 03:33:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=patchew-devel-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1634136870; cv=none; d=zohomail.com; s=zohoarc; b=NQu0UdSet/+Ksx7vDSE575/NFwb207bPnkvR+Aex22tJ3oBqkUJREMifqXH3atE3THws5PGLAQgP+LBPQLVSTUI+b+w65AwJzAqutJtHSO+vF4wP3FGUsxbmLp28e9vD86edUtxb9qXpNpHTvPRRK2CIki2dVMbyzBjZP8WM4F8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634136870; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=bknHb14YKUVGUv0Q/++UJ1GuSuhrNqlfbXJFvlIBNQg=; b=hkT9lXs5bjGHOmBVend2aiSbDlkU3Hv8O2V9mujk1+wTkdQztyMT4DV/0yvDULfWI23imVkRkn8p9cTAdYYXjgip3SvDAUU/OLBU0AR3JxmQeJeWohe0mVKGojci1+cFpTR/6b0LWcCe0XVcDjGG6pCe5bDykdglS6VA031OLmk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1634136870167891.9382407609578; Wed, 13 Oct 2021 07:54:30 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-529-wOs5coDSMqmS_5rwhNGlIg-1; Wed, 13 Oct 2021 10:54:25 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E317D10055BA; Wed, 13 Oct 2021 14:54:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DC0421981F; Wed, 13 Oct 2021 14:54:23 +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 CEEBF4ED3A; Wed, 13 Oct 2021 14:54:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19DEpoEo023830 for ; Wed, 13 Oct 2021 10:51:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id C2F2A5C3E0; Wed, 13 Oct 2021 14:51:50 +0000 (UTC) Received: from avogadro.lan (unknown [10.39.194.212]) by smtp.corp.redhat.com (Postfix) with ESMTP id 367B25C1A3 for ; Wed, 13 Oct 2021 14:51:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634136869; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=bknHb14YKUVGUv0Q/++UJ1GuSuhrNqlfbXJFvlIBNQg=; b=TjE0wMgRsjoAdFohPpI7iL+rK6nYpjTZYA2aAfZDf8RI67X9TCtFPYA1d/UBBmstKOov2/ gFhOTzD++76BNrHxVxb68WT6ztn7pxhXQbVqRPdRUwAhhVsBOHXc+5ti0FgWBZaLTjPQxP VEjndYow35YzFKsAtrIGyz4/XqBrAcQ= X-MC-Unique: wOs5coDSMqmS_5rwhNGlIg-1 From: Paolo Bonzini To: patchew-devel@redhat.com Date: Wed, 13 Oct 2021 16:51:49 +0200 Message-Id: <20211013145149.361359-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH] add "generation" field to message 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: , Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=patchew-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1634136872012100001 Content-Type: text/plain; charset="utf-8" Add a field that can be used to track changes to the mbox file. It changes every time a message receives a tag, or for a cover letter every time a message underneath receives a tag. This can be used to avoid downloading the same mbox again and again; for example the "patches" tool (https://github.com/stefanha/patches) had a similar feature, which it implemented using a hash of the mbox. Signed-off-by: Paolo Bonzini --- api/migrations/0061_message_gen.py | 18 +++++++++++++ api/models.py | 1 + api/rest.py | 1 + mods/tags.py | 6 +++++ tests/data/0036-simple-patch-review.mbox.gz | Bin 0 -> 276 bytes tests/test_tags.py | 27 ++++++++++++++++++++ 6 files changed, 53 insertions(+) create mode 100644 api/migrations/0061_message_gen.py create mode 100644 tests/data/0036-simple-patch-review.mbox.gz diff --git a/api/migrations/0061_message_gen.py b/api/migrations/0061_messa= ge_gen.py new file mode 100644 index 0000000..d4a8646 --- /dev/null +++ b/api/migrations/0061_message_gen.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.3 on 2021-10-13 14:23 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies =3D [ + ('api', '0060_auto_20210106_1120'), + ] + + operations =3D [ + migrations.AddField( + model_name=3D'message', + name=3D'gen', + field=3Dmodels.PositiveSmallIntegerField(default=3D0), + ), + ] diff --git a/api/models.py b/api/models.py index 5879466..18a09dd 100644 --- a/api/models.py +++ b/api/models.py @@ -593,6 +593,7 @@ class Message(models.Model): subject =3D HeaderFieldModel() stripped_subject =3D HeaderFieldModel(db_index=3DTrue) version =3D models.PositiveSmallIntegerField(default=3D0) + gen =3D models.PositiveSmallIntegerField(default=3D0) sender =3D jsonfield.JSONCharField(max_length=3D4096, db_index=3DTrue) recipients =3D jsonfield.JSONField() tags =3D jsonfield.JSONField(default=3D[]) diff --git a/api/rest.py b/api/rest.py index b723997..fd767e2 100644 --- a/api/rest.py +++ b/api/rest.py @@ -374,6 +374,7 @@ class BaseMessageSerializer(serializers.ModelSerializer= ): "date", "sender", "recipients", + "gen", ) fields =3D read_only_fields + ("tags",) =20 diff --git a/mods/tags.py b/mods/tags.py index e2308b3..9c7ba0d 100644 --- a/mods/tags.py +++ b/mods/tags.py @@ -71,6 +71,9 @@ series cover letter, patch mail body and their replies. new =3D self.look_for_tags(s, s) if set(old) !=3D set(new): s.tags =3D list(set(new)) + # The gen field for series is updated later + if s.is_patch: + s.gen +=3D 1 s.save() return True =20 @@ -127,6 +130,9 @@ series cover letter, patch mail body and their replies. if need_event: emit_event("SeriesReviewed", series=3Dseries) if updated: + if not series.is_patch: + series.gen +=3D 1 + series.save() emit_event("TagsUpdate", series=3Dseries) =20 if not series.topic.latest or newer_than(series, series.topic.late= st): diff --git a/tests/data/0036-simple-patch-review.mbox.gz b/tests/data/0036-= simple-patch-review.mbox.gz new file mode 100644 index 0000000000000000000000000000000000000000..c401938bd3772067dd50d511464= 9980fdf4378f9 GIT binary patch literal 276 zcmV+v0qg!BiwFo8@@8QG128Z%HZ5~$ZE$R5EpTCUV`wdMWp-(0cP?#WZ+HNWkV{X) zFc5_A{uO%%M@|TF8dWGfga8RqN^VsTPP3#&e$|Ov(qE6ON=3DV$0_OOSU*>C63TV26I zSY_ePnxixl=3DB_<&wa0EN#$;pl4QXrzJJf-8xJOkRYkCtB>wEGbMy#L-cnMhvFTp^@ z(gN75%6S~PU?pSZ*-(#8P4pBrKPgy|l`PG9&XbJIcuG_HDfIEr)mIz_(Ib^zG^N>9 zeqHdg#&4mW!n5Qfv|qRxD_Fh%;;mt|xNYvA*079dyI_5YZ@w8dLG(DO5Dr^3Fa+nU aAF(53iF=3D6$>}WgvuaF;%soW7e0RRBa6?|#{ literal 0 HcmV?d00001 diff --git a/tests/test_tags.py b/tests/test_tags.py index 101a39d..a9d4a5c 100755 --- a/tests/test_tags.py +++ b/tests/test_tags.py @@ -33,6 +33,33 @@ class ImportTest(PatchewTestCase): ) self.assertEquals(resp.status_code, 404) =20 + def test_message_generation(self): + resp =3D self.apply_and_retrieve( + "0001-simple-patch.mbox.gz", + self.p.id, + "20160628014747.20971-1-famz@redhat.com") + message =3D self.api_client.get(resp.data["message"]) + gen =3D message.data["gen"] + + resp =3D self.apply_and_retrieve( + "0036-simple-patch-review.mbox.gz", + self.p.id, + "20160628014747.20971-1-famz@redhat.com") + message =3D self.api_client.get(resp.data["message"]) + self.assertGreater(message.data["gen"], gen) + + def test_series_generation(self): + resp =3D self.apply_and_retrieve( + "0001-simple-patch.mbox.gz", + self.p.id, + "20160628014747.20971-1-famz@redhat.com") + gen =3D resp.data["gen"] + resp =3D self.apply_and_retrieve( + "0036-simple-patch-review.mbox.gz", + self.p.id, + "20160628014747.20971-1-famz@redhat.com") + self.assertGreater(resp.data["gen"], gen) + def test_rest_single(self): resp =3D self.apply_and_retrieve( "0003-single-patch-reviewed.mbox.gz", --=20 2.31.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://listman.redhat.com/mailman/listinfo/patchew-devel