[WIP PATCH 4/4] lib: Add "lastmod:" queries for filtering by last modification
authorAustin Clements <aclements@csail.mit.edu>
Mon, 13 Oct 2014 06:20:03 +0000 (02:20 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:05:14 +0000 (10:05 -0800)
d5/d2a70f3f9c1d94dfa3a734bd99ecff6c7413f2 [new file with mode: 0644]

diff --git a/d5/d2a70f3f9c1d94dfa3a734bd99ecff6c7413f2 b/d5/d2a70f3f9c1d94dfa3a734bd99ecff6c7413f2
new file mode 100644 (file)
index 0000000..4e2ea4c
--- /dev/null
@@ -0,0 +1,153 @@
+Return-Path: <aclements@csail.mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 6E559431FBF\r
+       for <notmuch@notmuchmail.org>; Sun, 12 Oct 2014 23:20:18 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.3\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id Cz8pLV56TWLf for <notmuch@notmuchmail.org>;\r
+       Sun, 12 Oct 2014 23:20:11 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-5.mit.edu (dmz-mailsec-scanner-5.mit.edu\r
+       [18.7.68.34])\r
+       by olra.theworths.org (Postfix) with ESMTP id E0116431FAF\r
+       for <notmuch@notmuchmail.org>; Sun, 12 Oct 2014 23:20:10 -0700 (PDT)\r
+X-AuditID: 12074422-f79436d000000c21-6d-543b6f1a72a1\r
+Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
+       (using TLS with cipher AES256-SHA (256/256 bits))\r
+       (Client did not present a certificate)\r
+       by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id 08.FC.03105.A1F6B345; Mon, 13 Oct 2014 02:20:10 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+       by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id s9D6K8Pb001787; \r
+       Mon, 13 Oct 2014 02:20:08 -0400\r
+Received: from drake.dyndns.org ([73.162.189.21]) (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s9D6K524031970\r
+       (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT);\r
+       Mon, 13 Oct 2014 02:20:07 -0400\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.84)\r
+       (envelope-from <aclements@csail.mit.edu>)\r
+       id 1XdYzF-0000UK-Be; Mon, 13 Oct 2014 02:20:05 -0400\r
+From: Austin Clements <aclements@csail.mit.edu>\r
+To: notmuch@notmuchmail.org\r
+Subject: [WIP PATCH 4/4] lib: Add "lastmod:" queries for filtering by last\r
+       modification\r
+Date: Mon, 13 Oct 2014 02:20:03 -0400\r
+Message-Id: <1413181203-1676-5-git-send-email-aclements@csail.mit.edu>\r
+X-Mailer: git-send-email 2.1.0\r
+In-Reply-To: <1413181203-1676-1-git-send-email-aclements@csail.mit.edu>\r
+References: <1413181203-1676-1-git-send-email-aclements@csail.mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFtrMIsWRmVeSWpSXmKPExsUixG6noiuVbx1isP+9lMX1mzOZHRg9nq26\r
+       xRzAGMVlk5Kak1mWWqRvl8CVsXVhF1PBXumKC5cesDcwzhbvYuTkkBAwkdhxZTEjhC0mceHe\r
+       erYuRi4OIYHZTBITZr5mhXA2Mko0Xm1jh3CWM0msOfMJKrOEUeLixs9sIP1sAvoSK9ZOYgWx\r
+       RQSkJXbenQ1kc3AwC6hJ/OlSAQkLC4RL3Jk3gQnEZhFQlTi37ilYK6+Am8S2r3/YIM6Qk9iw\r
+       +z/YSZwC7hIXJ55lBrGFgGqOtV1jmcDIv4CRYRWjbEpulW5uYmZOcWqybnFyYl5eapGuqV5u\r
+       ZoleakrpJkZw2Lgo7WD8eVDpEKMAB6MSD6/FH6sQIdbEsuLK3EOMkhxMSqK8AWnWIUJ8Sfkp\r
+       lRmJxRnxRaU5qcWHGCU4mJVEeN/aAOV4UxIrq1KL8mFS0hwsSuK8m37whQgJpCeWpGanphak\r
+       FsFkZTg4lCR4V+QBNQoWpaanVqRl5pQgpJk4OEGG8wANXwRSw1tckJhbnJkOkT/FqCglzvs9\r
+       FyghAJLIKM2D64XF9StGcaBXhHnjQNp5gCkBrvsV0GAmoMFHu8xBBpckIqSkGhinL05mPHq3\r
+       9eiuj1uMVjG/1f3dajRhz/NDD1YplkYvPyGYraJXHrmLvXfrj5rl8+dxtm/Suayxge2Af39P\r
+       S3WpYqzsl6OZ/csC1iUJMJ5x2lYU+oHvi0hezmy1HUecvAU1XySu3nV50ocVlc9Xbdf4vH7p\r
+       o9/7H5Xt+LxkfUFcgqIt0ye+gEdtSizFGYmGWsxFxYkAgkepZ8YCAAA=\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 13 Oct 2014 06:20:18 -0000\r
+\r
+From: Austin Clements <amdragon@mit.edu>\r
+\r
+XXX Includes reference to notmuch search --db-revision, which doesn't\r
+exist.\r
+---\r
+ doc/man7/notmuch-search-terms.rst | 8 ++++++++\r
+ lib/database-private.h            | 1 +\r
+ lib/database.cc                   | 4 ++++\r
+ 3 files changed, 13 insertions(+)\r
+\r
+diff --git a/doc/man7/notmuch-search-terms.rst b/doc/man7/notmuch-search-terms.rst\r
+index 1acdaa0..df76e39 100644\r
+--- a/doc/man7/notmuch-search-terms.rst\r
++++ b/doc/man7/notmuch-search-terms.rst\r
+@@ -52,6 +52,8 @@ indicate user-supplied values):\r
\r
+ -  date:<since>..<until>\r
\r
++-  lastmod:<since>..<until>\r
++\r
+ The **from:** prefix is used to match the name or address of the sender\r
+ of an email message.\r
\r
+@@ -118,6 +120,12 @@ The time range can also be specified using timestamps with a syntax of:\r
+ Each timestamp is a number representing the number of seconds since\r
+ 1970-01-01 00:00:00 UTC.\r
\r
++The **lastmod:** prefix can be used to restrict the result by the\r
++database revision number of when messages were last modified (tags\r
++were added/removed or filenames changed).  This is usually used in\r
++conjunction with the **--db-revision** argument to **notmuch search**\r
++to find messages that have changed since an earlier query.\r
++\r
+ In addition to individual terms, multiple terms can be combined with\r
+ Boolean operators ( **and**, **or**, **not** , etc.). Each term in the\r
+ query will be implicitly connected by a logical AND if no explicit\r
+diff --git a/lib/database-private.h b/lib/database-private.h\r
+index 0977229..cbca1de 100644\r
+--- a/lib/database-private.h\r
++++ b/lib/database-private.h\r
+@@ -163,6 +163,7 @@ struct _notmuch_database {\r
+     Xapian::TermGenerator *term_gen;\r
+     Xapian::ValueRangeProcessor *value_range_processor;\r
+     Xapian::ValueRangeProcessor *date_range_processor;\r
++    Xapian::ValueRangeProcessor *last_mod_range_processor;\r
+ };\r
\r
+ /* Prior to database version 3, features were implied by the database\r
+diff --git a/lib/database.cc b/lib/database.cc\r
+index 9bec170..f9aa45d 100644\r
+--- a/lib/database.cc\r
++++ b/lib/database.cc\r
+@@ -913,6 +913,7 @@ notmuch_database_open (const char *path,\r
+       notmuch->term_gen->set_stemmer (Xapian::Stem ("english"));\r
+       notmuch->value_range_processor = new Xapian::NumberValueRangeProcessor (NOTMUCH_VALUE_TIMESTAMP);\r
+       notmuch->date_range_processor = new ParseTimeValueRangeProcessor (NOTMUCH_VALUE_TIMESTAMP);\r
++      notmuch->last_mod_range_processor = new Xapian::NumberValueRangeProcessor (NOTMUCH_VALUE_LAST_MOD, "lastmod:");\r
\r
+       notmuch->query_parser->set_default_op (Xapian::Query::OP_AND);\r
+       notmuch->query_parser->set_database (*notmuch->xapian_db);\r
+@@ -920,6 +921,7 @@ notmuch_database_open (const char *path,\r
+       notmuch->query_parser->set_stemming_strategy (Xapian::QueryParser::STEM_SOME);\r
+       notmuch->query_parser->add_valuerangeprocessor (notmuch->value_range_processor);\r
+       notmuch->query_parser->add_valuerangeprocessor (notmuch->date_range_processor);\r
++      notmuch->query_parser->add_valuerangeprocessor (notmuch->last_mod_range_processor);\r
\r
+       for (i = 0; i < ARRAY_SIZE (BOOLEAN_PREFIX_EXTERNAL); i++) {\r
+           prefix_t *prefix = &BOOLEAN_PREFIX_EXTERNAL[i];\r
+@@ -991,6 +993,8 @@ notmuch_database_close (notmuch_database_t *notmuch)\r
+     notmuch->value_range_processor = NULL;\r
+     delete notmuch->date_range_processor;\r
+     notmuch->date_range_processor = NULL;\r
++    delete notmuch->last_mod_range_processor;\r
++    notmuch->last_mod_range_processor = NULL;\r
\r
+     return status;\r
+ }\r
+-- \r
+2.1.0\r
+\r