1 Return-Path: <bremner@tesseract.cs.unb.ca>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by arlo.cworth.org (Postfix) with ESMTP id C0F4D6DE1760
\r
6 for <notmuch@notmuchmail.org>; Sun, 9 Aug 2015 02:27:14 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
11 X-Spam-Status: No, score=0.139 tagged_above=-999 required=5 tests=[AWL=0.129,
\r
12 T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] autolearn=disabled
\r
13 Received: from arlo.cworth.org ([127.0.0.1])
\r
14 by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id FkiZULXQoo-i for <notmuch@notmuchmail.org>;
\r
16 Sun, 9 Aug 2015 02:27:12 -0700 (PDT)
\r
17 Received: from gitolite.debian.net (gitolite.debian.net [87.98.215.224])
\r
18 by arlo.cworth.org (Postfix) with ESMTPS id 7E24B6DE100F
\r
19 for <notmuch@notmuchmail.org>; Sun, 9 Aug 2015 02:27:12 -0700 (PDT)
\r
20 Received: from remotemail by gitolite.debian.net with local (Exim 4.80)
\r
21 (envelope-from <bremner@tesseract.cs.unb.ca>)
\r
22 id 1ZOMrC-0005WB-Nh; Sun, 09 Aug 2015 09:25:30 +0000
\r
23 Received: (nullmailer pid 7069 invoked by uid 1000); Sun, 09 Aug 2015
\r
25 From: David Bremner <david@tethera.net>
\r
26 To: notmuch@notmuchmail.org
\r
27 Subject: [PATCH 5/5] lib: Add "lastmod:" queries for filtering by last
\r
29 Date: Sun, 9 Aug 2015 11:24:45 +0200
\r
30 Message-Id: <1439112285-6681-6-git-send-email-david@tethera.net>
\r
31 X-Mailer: git-send-email 2.1.4
\r
32 In-Reply-To: <1439112285-6681-1-git-send-email-david@tethera.net>
\r
33 References: <1439112285-6681-1-git-send-email-david@tethera.net>
\r
34 X-BeenThere: notmuch@notmuchmail.org
\r
35 X-Mailman-Version: 2.1.18
\r
37 List-Id: "Use and development of the notmuch mail system."
\r
38 <notmuch.notmuchmail.org>
\r
39 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
40 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
41 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
\r
42 List-Post: <mailto:notmuch@notmuchmail.org>
\r
43 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
44 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
45 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
46 X-List-Received-Date: Sun, 09 Aug 2015 09:27:15 -0000
\r
48 From: Austin Clements <amdragon@mit.edu>
\r
50 The implementation is essentially the same as the date range search
\r
51 prior to Jani's fancy date parser.
\r
53 doc/man7/notmuch-search-terms.rst | 8 ++++++++
\r
54 lib/database-private.h | 1 +
\r
55 lib/database.cc | 4 ++++
\r
56 test/T570-revision-tracking.sh | 17 +++++++++++++++++
\r
57 4 files changed, 30 insertions(+)
\r
59 diff --git a/doc/man7/notmuch-search-terms.rst b/doc/man7/notmuch-search-terms.rst
\r
60 index 1d27ac1..e71a525 100644
\r
61 --- a/doc/man7/notmuch-search-terms.rst
\r
62 +++ b/doc/man7/notmuch-search-terms.rst
\r
63 @@ -54,6 +54,8 @@ indicate user-supplied values):
\r
65 - date:<since>..<until>
\r
67 +- lastmod:<since>..<until>
\r
69 The **from:** prefix is used to match the name or address of the sender
\r
70 of an email message.
\r
72 @@ -124,6 +126,12 @@ The time range can also be specified using timestamps with a syntax of:
\r
73 Each timestamp is a number representing the number of seconds since
\r
74 1970-01-01 00:00:00 UTC.
\r
76 +The **lastmod:** prefix can be used to restrict the result by the
\r
77 +database revision number of when messages were last modified (tags
\r
78 +were added/removed or filenames changed). This is usually used in
\r
79 +conjunction with the **--uuid** argument to **notmuch search**
\r
80 +to find messages that have changed since an earlier query.
\r
85 diff --git a/lib/database-private.h b/lib/database-private.h
\r
86 index 4e93257..3fb10f7 100644
\r
87 --- a/lib/database-private.h
\r
88 +++ b/lib/database-private.h
\r
89 @@ -176,6 +176,7 @@ struct _notmuch_database {
\r
90 Xapian::TermGenerator *term_gen;
\r
91 Xapian::ValueRangeProcessor *value_range_processor;
\r
92 Xapian::ValueRangeProcessor *date_range_processor;
\r
93 + Xapian::ValueRangeProcessor *last_mod_range_processor;
\r
96 /* Prior to database version 3, features were implied by the database
\r
97 diff --git a/lib/database.cc b/lib/database.cc
\r
98 index fc78769..bab3334 100644
\r
99 --- a/lib/database.cc
\r
100 +++ b/lib/database.cc
\r
101 @@ -1000,6 +1000,7 @@ notmuch_database_open_verbose (const char *path,
\r
102 notmuch->term_gen->set_stemmer (Xapian::Stem ("english"));
\r
103 notmuch->value_range_processor = new Xapian::NumberValueRangeProcessor (NOTMUCH_VALUE_TIMESTAMP);
\r
104 notmuch->date_range_processor = new ParseTimeValueRangeProcessor (NOTMUCH_VALUE_TIMESTAMP);
\r
105 + notmuch->last_mod_range_processor = new Xapian::NumberValueRangeProcessor (NOTMUCH_VALUE_LAST_MOD, "lastmod:");
\r
107 notmuch->query_parser->set_default_op (Xapian::Query::OP_AND);
\r
108 notmuch->query_parser->set_database (*notmuch->xapian_db);
\r
109 @@ -1007,6 +1008,7 @@ notmuch_database_open_verbose (const char *path,
\r
110 notmuch->query_parser->set_stemming_strategy (Xapian::QueryParser::STEM_SOME);
\r
111 notmuch->query_parser->add_valuerangeprocessor (notmuch->value_range_processor);
\r
112 notmuch->query_parser->add_valuerangeprocessor (notmuch->date_range_processor);
\r
113 + notmuch->query_parser->add_valuerangeprocessor (notmuch->last_mod_range_processor);
\r
115 for (i = 0; i < ARRAY_SIZE (BOOLEAN_PREFIX_EXTERNAL); i++) {
\r
116 prefix_t *prefix = &BOOLEAN_PREFIX_EXTERNAL[i];
\r
117 @@ -1085,6 +1087,8 @@ notmuch_database_close (notmuch_database_t *notmuch)
\r
118 notmuch->value_range_processor = NULL;
\r
119 delete notmuch->date_range_processor;
\r
120 notmuch->date_range_processor = NULL;
\r
121 + delete notmuch->last_mod_range_processor;
\r
122 + notmuch->last_mod_range_processor = NULL;
\r
126 diff --git a/test/T570-revision-tracking.sh b/test/T570-revision-tracking.sh
\r
127 index 74e3ba9..55337e6 100755
\r
128 --- a/test/T570-revision-tracking.sh
\r
129 +++ b/test/T570-revision-tracking.sh
\r
130 @@ -73,4 +73,21 @@ test_expect_success 'tag succeeds with correct uuid' \
\r
131 test_expect_code 1 'tag fails with incorrect uuid' \
\r
132 "notmuch tag --uuid=this-is-no-uuid '*' +test2"
\r
134 +test_begin_subtest 'lastmod:0.. matches everything'
\r
135 +total=$(notmuch count '*')
\r
136 +modtotal=$(notmuch count lastmod:0..)
\r
137 +test_expect_equal "$total" "$modtotal"
\r
139 +test_begin_subtest 'lastmod:1000000.. matches nothing'
\r
140 +modtotal=$(notmuch count lastmod:1000000..)
\r
141 +test_expect_equal 0 "$modtotal"
\r
143 +test_begin_subtest 'exclude one message using lastmod'
\r
144 +lastmod=$(notmuch count --output=modifications '*' | cut -f2)
\r
145 +total=$(notmuch count '*')
\r
146 +notmuch tag +4EFC743A.3060609@april.org id:4EFC743A.3060609@april.org
\r
147 +subtotal=$(notmuch count lastmod:..$lastmod)
\r
148 +result=$(($subtotal == $total-1))
\r
149 +test_expect_equal 1 "$result"
\r