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 2C3BA6DE1785
\r
6 for <notmuch@notmuchmail.org>; Fri, 5 Jun 2015 10:31:40 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
11 X-Spam-Status: No, score=0.234 tagged_above=-999 required=5 tests=[AWL=0.224,
\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 aRPszRHIhMQF for <notmuch@notmuchmail.org>;
\r
16 Fri, 5 Jun 2015 10:31:38 -0700 (PDT)
\r
17 Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net
\r
19 by arlo.cworth.org (Postfix) with ESMTPS id 0EFC06DE18DF
\r
20 for <notmuch@notmuchmail.org>; Fri, 5 Jun 2015 10:31:38 -0700 (PDT)
\r
21 Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim
\r
22 4.80) (envelope-from <bremner@tesseract.cs.unb.ca>)
\r
23 id 1Z0vRM-0002nr-CN; Fri, 05 Jun 2015 17:29:56 +0000
\r
24 Received: (nullmailer pid 24258 invoked by uid 1000); Fri, 05 Jun 2015
\r
26 From: David Bremner <david@tethera.net>
\r
27 To: notmuch@notmuchmail.org
\r
28 Subject: [PATCH 6/6] lib: Add "lastmod:" queries for filtering by last
\r
30 Date: Fri, 5 Jun 2015 19:28:38 +0200
\r
31 Message-Id: <1433525318-23756-7-git-send-email-david@tethera.net>
\r
32 X-Mailer: git-send-email 2.1.4
\r
33 In-Reply-To: <1433525318-23756-1-git-send-email-david@tethera.net>
\r
34 References: <1432936375-astroid-4-0i1n6yczs2-1520@strange>
\r
35 <1433525318-23756-1-git-send-email-david@tethera.net>
\r
36 X-BeenThere: notmuch@notmuchmail.org
\r
37 X-Mailman-Version: 2.1.18
\r
39 List-Id: "Use and development of the notmuch mail system."
\r
40 <notmuch.notmuchmail.org>
\r
41 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
42 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
43 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
\r
44 List-Post: <mailto:notmuch@notmuchmail.org>
\r
45 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
46 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
47 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
48 X-List-Received-Date: Fri, 05 Jun 2015 17:31:40 -0000
\r
50 From: Austin Clements <amdragon@mit.edu>
\r
52 The implementation is essentially the same as the date range search
\r
53 prior to Jani's fancy date parser.
\r
55 doc/man7/notmuch-search-terms.rst | 8 ++++++++
\r
56 lib/database-private.h | 1 +
\r
57 lib/database.cc | 4 ++++
\r
58 test/T570-revision-tracking.sh | 18 ++++++++++++++++++
\r
59 4 files changed, 31 insertions(+)
\r
61 diff --git a/doc/man7/notmuch-search-terms.rst b/doc/man7/notmuch-search-terms.rst
\r
62 index 1d27ac1..d9f213e 100644
\r
63 --- a/doc/man7/notmuch-search-terms.rst
\r
64 +++ b/doc/man7/notmuch-search-terms.rst
\r
65 @@ -54,6 +54,8 @@ indicate user-supplied values):
\r
67 - date:<since>..<until>
\r
69 +- lastmod:<since>..<until>
\r
71 The **from:** prefix is used to match the name or address of the sender
\r
72 of an email message.
\r
74 @@ -124,6 +126,12 @@ The time range can also be specified using timestamps with a syntax of:
\r
75 Each timestamp is a number representing the number of seconds since
\r
76 1970-01-01 00:00:00 UTC.
\r
78 +The **lastmod:** prefix can be used to restrict the result by the
\r
79 +database revision number of when messages were last modified (tags
\r
80 +were added/removed or filenames changed). This is usually used in
\r
81 +conjunction with the **--db-revision** argument to **notmuch search**
\r
82 +to find messages that have changed since an earlier query.
\r
87 diff --git a/lib/database-private.h b/lib/database-private.h
\r
88 index 4e93257..3fb10f7 100644
\r
89 --- a/lib/database-private.h
\r
90 +++ b/lib/database-private.h
\r
91 @@ -176,6 +176,7 @@ struct _notmuch_database {
\r
92 Xapian::TermGenerator *term_gen;
\r
93 Xapian::ValueRangeProcessor *value_range_processor;
\r
94 Xapian::ValueRangeProcessor *date_range_processor;
\r
95 + Xapian::ValueRangeProcessor *last_mod_range_processor;
\r
98 /* Prior to database version 3, features were implied by the database
\r
99 diff --git a/lib/database.cc b/lib/database.cc
\r
100 index ba8b8d9..a7daa44 100644
\r
101 --- a/lib/database.cc
\r
102 +++ b/lib/database.cc
\r
103 @@ -986,6 +986,7 @@ notmuch_database_open_verbose (const char *path,
\r
104 notmuch->term_gen->set_stemmer (Xapian::Stem ("english"));
\r
105 notmuch->value_range_processor = new Xapian::NumberValueRangeProcessor (NOTMUCH_VALUE_TIMESTAMP);
\r
106 notmuch->date_range_processor = new ParseTimeValueRangeProcessor (NOTMUCH_VALUE_TIMESTAMP);
\r
107 + notmuch->last_mod_range_processor = new Xapian::NumberValueRangeProcessor (NOTMUCH_VALUE_LAST_MOD, "lastmod:");
\r
109 notmuch->query_parser->set_default_op (Xapian::Query::OP_AND);
\r
110 notmuch->query_parser->set_database (*notmuch->xapian_db);
\r
111 @@ -993,6 +994,7 @@ notmuch_database_open_verbose (const char *path,
\r
112 notmuch->query_parser->set_stemming_strategy (Xapian::QueryParser::STEM_SOME);
\r
113 notmuch->query_parser->add_valuerangeprocessor (notmuch->value_range_processor);
\r
114 notmuch->query_parser->add_valuerangeprocessor (notmuch->date_range_processor);
\r
115 + notmuch->query_parser->add_valuerangeprocessor (notmuch->last_mod_range_processor);
\r
117 for (i = 0; i < ARRAY_SIZE (BOOLEAN_PREFIX_EXTERNAL); i++) {
\r
118 prefix_t *prefix = &BOOLEAN_PREFIX_EXTERNAL[i];
\r
119 @@ -1071,6 +1073,8 @@ notmuch_database_close (notmuch_database_t *notmuch)
\r
120 notmuch->value_range_processor = NULL;
\r
121 delete notmuch->date_range_processor;
\r
122 notmuch->date_range_processor = NULL;
\r
123 + delete notmuch->last_mod_range_processor;
\r
124 + notmuch->last_mod_range_processor = NULL;
\r
128 diff --git a/test/T570-revision-tracking.sh b/test/T570-revision-tracking.sh
\r
129 index bb09bf6..7ad8b2a 100755
\r
130 --- a/test/T570-revision-tracking.sh
\r
131 +++ b/test/T570-revision-tracking.sh
\r
132 @@ -72,4 +72,22 @@ test_expect_success 'tag succeeds with correct db revision' \
\r
134 test_expect_code 1 'tag fails with incorrect db revision' \
\r
135 "notmuch show --db-revision=this-is-no-uuid '*' +test2"
\r
137 +test_begin_subtest 'lastmod:0.. matches everything'
\r
138 +total=$(notmuch count '*')
\r
139 +modtotal=$(notmuch count lastmod:0..)
\r
140 +test_expect_equal "$total" "$modtotal"
\r
142 +test_begin_subtest 'lastmod:1000000.. matches nothing'
\r
143 +modtotal=$(notmuch count lastmod:1000000..)
\r
144 +test_expect_equal 0 "$modtotal"
\r
146 +test_begin_subtest 'exclude one message using lastmod'
\r
147 +lastmod=$(notmuch count --output=modifications '*' | cut -f2)
\r
148 +total=$(notmuch count '*')
\r
149 +notmuch tag +4EFC743A.3060609@april.org id:4EFC743A.3060609@april.org
\r
150 +subtotal=$(notmuch count lastmod:..$lastmod)
\r
151 +result=$(($subtotal == $total-1))
\r
152 +test_expect_equal 1 "$result"
\r