From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id kNepNNP58GI+GAEAbAwnHQ (envelope-from ) for ; Mon, 08 Aug 2022 13:56:03 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id GLCeNNP58GJogQEAauVa8A (envelope-from ) for ; Mon, 08 Aug 2022 13:56:03 +0200 Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (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 aspmx1.migadu.com (Postfix) with ESMTPS id 6692238C90 for ; Mon, 8 Aug 2022 13:56:03 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 16E225F370; Mon, 8 Aug 2022 11:50:11 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id 5B0185E545 for ; Mon, 8 Aug 2022 11:50:07 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id 4D6395FBC0; Mon, 8 Aug 2022 07:50:06 -0400 (EDT) Received: (nullmailer pid 1566852 invoked by uid 1000); Mon, 08 Aug 2022 11:50:05 -0000 From: David Bremner To: Ico , notmuch@notmuchmail.org Subject: [PATCH] WIP: provide relative lastmod sexp queries Date: Mon, 8 Aug 2022 08:50:00 -0300 Message-Id: <20220808115000.1559492-1-david@tethera.net> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20161202140115.62194.22060@localhost.localdomain> References: <20161202140115.62194.22060@localhost.localdomain> MIME-Version: 1.0 Message-ID-Hash: QFXMNRI34OQZVLOO5ERB5L4BH6ZEKR6V X-Message-ID-Hash: QFXMNRI34OQZVLOO5ERB5L4BH6ZEKR6V X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1659959763; h=from:from: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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=kJMZSbQBYxF5QXVTLC3YdOnCYgRijrObK84cshVUDP0=; b=G7ioIS7sKMWpETDnNMWS9PAWa4n/s4/AI+oYsgZCZCR9n5TF6tX8Mnd41nyt3qCqpxFcQe nL6uiDcTxb7CfexOFzC713mkunJ0gWpf3FoH7lzZ/cp7rsEvP0j6UnWx07g37kGAuV5f6H INyoCSj2dqRhKRLu5FSzmDjgmJNVg6PCw4kRRuhj9qBdLHD2l0cO313lEcrH5BbRLgB6aE yaQrQJnx6ryFOJ1JX/ISDt3gQMHZt+ns+eUna5GcKKxdpxcYUg9NT5ULqvJLrPKCwK0Giy wKfq7eR/O2PhkEFR6zy/ToE3Rlm1zlOrkap5uQdLbsUewFw9/mlXVLFaNzpFJg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1659959763; a=rsa-sha256; cv=none; b=nCog/epcslEDrHVJ3Z7ZeRto5ETGG3ssuqOzPyS/RvMH3Z0n+kxF3vnJhRh+qZhr7HlIMf WxibzrF/bdCMi/+SQ9g88+2LPFMLKjHrF+Qb+cwm6AlI4i2d7Oh3tssBC0Co/TyqLr0z42 V2LlKhm5CdnNS3SgnJGlq0T3kSl0zbp+kfm0hLIF8QMUe+Ie5YNEg34bdvxlxJC9JLrrs8 FNF22SWrq924eNNw4o+dZGa8HFR/E2VOhiNrRTS5kgFacOcZi1OJuNHp+fGcCwyzJr1Z5o uijIJNVgkNZXQ2J/TU+XJ4NxzW/S5aAub+p6rmYO5bhxN8VW6Y+t0cYqKo9Ftw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: 5.68 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 6692238C90 X-Spam-Score: 5.68 X-Migadu-Scanner: scn1.migadu.com X-TUID: Dhm8kyuA644c --- I haven't looked carefully at how much work it would be to add to the infix parser yet. I suspect it means adding a new RangeProcessor class modelled on ParseTimeRangeProcessor. Maybe some of the logic from _parse_sexp_range could be shared with the other parser. lib/parse-sexp.cc | 6 ++++++ test/T570-revision-tracking.sh | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/parse-sexp.cc b/lib/parse-sexp.cc index 0f14d8b7..e9ef4268 100644 --- a/lib/parse-sexp.cc +++ b/lib/parse-sexp.cc @@ -575,6 +575,9 @@ _sexp_parse_range (notmuch_database_t *notmuch, const _sexp_prefix_t *prefix, return NOTMUCH_STATUS_BAD_QUERY_SYNTAX; } + if (from_idx < 0) + from_idx += notmuch_database_get_revision (notmuch, NULL); + try { if (EMPTY_STRING (to)) to_idx = LONG_MAX; @@ -585,6 +588,9 @@ _sexp_parse_range (notmuch_database_t *notmuch, const _sexp_prefix_t *prefix, return NOTMUCH_STATUS_BAD_QUERY_SYNTAX; } + if (to_idx < 0) + to_idx += notmuch_database_get_revision (notmuch, NULL); + output = Xapian::Query (Xapian::Query::OP_VALUE_RANGE, NOTMUCH_VALUE_LAST_MOD, Xapian::sortable_serialise (from_idx), Xapian::sortable_serialise (to_idx)); diff --git a/test/T570-revision-tracking.sh b/test/T570-revision-tracking.sh index e1cc684d..aaa45468 100755 --- a/test/T570-revision-tracking.sh +++ b/test/T570-revision-tracking.sh @@ -95,4 +95,12 @@ subtotal=$(notmuch count lastmod:..$lastmod) result=$(($subtotal == $total-1)) test_expect_equal 1 "$result" +if [ $NOTMUCH_HAVE_SFSEXP -eq 1 ]; then + test_begin_subtest 'exclude one message using negative lastmod (sexp)' + total=$(notmuch count '*') + notmuch tag +${RANDOM} id:4EFC743A.3060609@april.org + count=$(notmuch count --query=sexp '(lastmod -1 *)') + test_expect_equal 1 "$count" +fi + test_done -- 2.35.2