1 Return-Path: <amdragon@mit.edu>
\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 olra.theworths.org (Postfix) with ESMTP id C5281429E2E
\r
6 for <notmuch@notmuchmail.org>; Sun, 6 Jan 2013 12:23:15 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id 95HBKNzJwkvI for <notmuch@notmuchmail.org>;
\r
16 Sun, 6 Jan 2013 12:23:14 -0800 (PST)
\r
17 Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id F3321431FAE
\r
20 for <notmuch@notmuchmail.org>; Sun, 6 Jan 2013 12:23:13 -0800 (PST)
\r
21 X-AuditID: 12074424-b7f4e6d0000004ca-8d-50e9dd312204
\r
22 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])
\r
23 by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 60.4E.01226.13DD9E05; Sun, 6 Jan 2013 15:23:13 -0500 (EST)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id r06KNAQI016495;
\r
27 Sun, 6 Jan 2013 15:23:10 -0500
\r
28 Received: from drake.dyndns.org (a069.catapulsion.net [70.36.81.69])
\r
29 (authenticated bits=0)
\r
30 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
31 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id r06KMxF7020356
\r
32 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
33 Sun, 6 Jan 2013 15:23:06 -0500 (EST)
\r
34 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)
\r
35 (envelope-from <amdragon@mit.edu>)
\r
36 id 1Trwk7-0007YJ-Oq; Sun, 06 Jan 2013 15:22:51 -0500
\r
37 From: Austin Clements <amdragon@MIT.EDU>
\r
38 To: notmuch@notmuchmail.org
\r
39 Subject: [PATCH v5 5/6] dump/restore: Use Xapian queries for batch-tag format
\r
40 Date: Sun, 6 Jan 2013 15:22:41 -0500
\r
41 Message-Id: <1357503762-28759-6-git-send-email-amdragon@mit.edu>
\r
42 X-Mailer: git-send-email 1.7.10.4
\r
43 In-Reply-To: <1357503762-28759-1-git-send-email-amdragon@mit.edu>
\r
44 References: <1357503762-28759-1-git-send-email-amdragon@mit.edu>
\r
45 X-Brightmail-Tracker:
\r
46 H4sIAAAAAAAAA+NgFrrBIsWRmVeSWpSXmKPExsUixCmqrWt492WAwYNVihY3WrsZLZqmO1us
\r
47 nstjcf3mTGaLNyvnsTqweuycdZfd4/DXhSwet+6/Zvd4tuoWs8eWQ++ZA1ijuGxSUnMyy1KL
\r
48 9O0SuDK+9kxmLpihV9HyfwtLA+M8lS5GTg4JAROJU/OWskPYYhIX7q1n62Lk4hAS2Mco0XB9
\r
49 NZSznlHi8neYzH4miWebD7NCOHMZJbY2vWEF6WcT0JDYtn85I4gtIiAtsfPubLAiZoEmRolr
\r
50 m+aygSSEBXwlXk1+ztLFyMHBIqAqselOGYjJK+Ag8W2LD8QZihLdzyawgYQ5BRwlPs6TBQkL
\r
51 AVXc2XGffQIj/wJGhlWMsim5Vbq5iZk5xanJusXJiXl5qUW65nq5mSV6qSmlmxhBAcjuorKD
\r
52 sfmQ0iFGAQ5GJR7eCztfBAixJpYVV+YeYpTkYFIS5d198WWAEF9SfkplRmJxRnxRaU5q8SFG
\r
53 CQ5mJRHefceAcrwpiZVVqUX5MClpDhYlcd7rKTf9hQTSE0tSs1NTC1KLYLIyHBxKErxLbgM1
\r
54 ChalpqdWpGXmlCCkmTg4QYbzAA1fD1LDW1yQmFucmQ6RP8WoKCXOuxIkIQCSyCjNg+uFJYhX
\r
55 jOJArwjzbgWp4gEmF7juV0CDmYAGpz5+DjK4JBEhJdXAmFn/f8/myMfpJQ5z9fmPF4U7tCyV
\r
56 SE3YcnLjHj8Jn6+vEm/I/uLapxjBziVe1Wgid/M6z+xJHWe/sx7n2am7wfu2fJdZS973n9ft
\r
57 o7bpCs9XnB+qxSUj+3xr+tGV3xwUnrV+ZHvHYj6JRW3Hf+/pxb53d8k+NrCZVW+/292m5+7q
\r
58 ZF/xorY6JZbijERDLeai4kQA9a792+sCAAA=
\r
59 Cc: tomi.ollila@iki.fi
\r
60 X-BeenThere: notmuch@notmuchmail.org
\r
61 X-Mailman-Version: 2.1.13
\r
63 List-Id: "Use and development of the notmuch mail system."
\r
64 <notmuch.notmuchmail.org>
\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
66 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
68 List-Post: <mailto:notmuch@notmuchmail.org>
\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
71 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
72 X-List-Received-Date: Sun, 06 Jan 2013 20:23:16 -0000
\r
74 This switches the new batch-tag format away from using a home-grown
\r
75 hex-encoding scheme for message IDs in the dump to simply using Xapian
\r
76 queries with Xapian quoting syntax.
\r
78 This has a variety of advantages beyond presenting a cleaner and more
\r
79 consistent interface. Foremost is that it will dramatically simplify
\r
80 the quoting for batch tagging, which shares the same input format.
\r
81 While the hex-encoding is no better or worse for the simple ID queries
\r
82 used by dump/restore, it becomes onerous for general-purpose queries
\r
83 used in batch tagging. It also better handles strange cases like
\r
84 "id:foo and bar", since this is no longer syntactically valid.
\r
86 notmuch-dump.c | 11 ++++++-----
\r
87 notmuch-restore.c | 27 +++++++++++++++------------
\r
88 tag-util.c | 6 ------
\r
89 test/dump-restore | 28 ++++++++++++++++++++++------
\r
90 4 files changed, 43 insertions(+), 29 deletions(-)
\r
92 diff --git a/notmuch-dump.c b/notmuch-dump.c
\r
93 index 5bbda36..a3244e0 100644
\r
94 --- a/notmuch-dump.c
\r
95 +++ b/notmuch-dump.c
\r
98 #include "notmuch-client.h"
\r
99 #include "dump-restore-private.h"
\r
100 +#include "string-util.h"
\r
103 notmuch_dump_command (unused (void *ctx), int argc, char *argv[])
\r
104 @@ -144,13 +145,13 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[])
\r
105 if (output_format == DUMP_FORMAT_SUP) {
\r
106 fputs (")\n", output);
\r
108 - if (hex_encode (notmuch, message_id,
\r
109 - &buffer, &buffer_size) != HEX_SUCCESS) {
\r
110 - fprintf (stderr, "Error: failed to hex-encode msg-id %s\n",
\r
112 + if (make_boolean_term (notmuch, "id", message_id,
\r
113 + &buffer, &buffer_size)) {
\r
114 + fprintf (stderr, "Error quoting message id %s: %s\n",
\r
115 + message_id, strerror (errno));
\r
118 - fprintf (output, " -- id:%s\n", buffer);
\r
119 + fprintf (output, " -- %s\n", buffer);
\r
122 notmuch_message_destroy (message);
\r
123 diff --git a/notmuch-restore.c b/notmuch-restore.c
\r
124 index 96834c0..81d4d98 100644
\r
125 --- a/notmuch-restore.c
\r
126 +++ b/notmuch-restore.c
\r
127 @@ -212,7 +212,7 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])
\r
128 INTERNAL_ERROR ("compile time constant regex failed.");
\r
131 - char *query_string;
\r
132 + char *query_string, *prefix, *term;
\r
134 if (line_ctx != NULL)
\r
135 talloc_free (line_ctx);
\r
136 @@ -225,19 +225,22 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])
\r
137 &query_string, tag_ops);
\r
140 - if (strncmp ("id:", query_string, 3) != 0) {
\r
141 - fprintf (stderr, "Warning: unsupported query: %s\n", query_string);
\r
142 + ret = parse_boolean_term (line_ctx, query_string,
\r
144 + if (ret && errno == EINVAL) {
\r
145 + fprintf (stderr, "Warning: cannot parse query: %s (skipping)\n", query_string);
\r
147 + } else if (ret) {
\r
148 + /* This is more fatal (e.g., out of memory) */
\r
149 + fprintf (stderr, "Error parsing query: %s\n",
\r
150 + strerror (errno));
\r
153 + } else if (strcmp ("id", prefix) != 0) {
\r
154 + fprintf (stderr, "Warning: not an id query: %s (skipping)\n", query_string);
\r
157 - /* delete id: from front of string; tag_message
\r
158 - * expects a raw message-id.
\r
160 - * XXX: Note that query string id:foo and bar will be
\r
161 - * interpreted as a message id "foo and bar". This
\r
162 - * should eventually be fixed to give a better error
\r
165 - query_string = query_string + 3;
\r
166 + query_string = term;
\r
170 diff --git a/tag-util.c b/tag-util.c
\r
171 index 705b7ba..e4e5dda 100644
\r
174 @@ -124,12 +124,6 @@ parse_tag_line (void *ctx, char *line,
\r
177 /* tok now points to the query string */
\r
178 - if (hex_decode_inplace (tok) != HEX_SUCCESS) {
\r
179 - ret = line_error (TAG_PARSE_INVALID, line_for_error,
\r
180 - "hex decoding of query %s failed", tok);
\r
184 *query_string = tok;
\r
187 diff --git a/test/dump-restore b/test/dump-restore
\r
188 index 6a989b6..f076c12 100755
\r
189 --- a/test/dump-restore
\r
190 +++ b/test/dump-restore
\r
191 @@ -195,23 +195,39 @@ a
\r
193 # the previous line was blank; also no yelling please
\r
194 +%zz -- id:whatever
\r
198 # the next non-comment line should report an an empty tag error for
\r
199 # batch tagging, but not for restore
\r
200 + +e -- id:20091117232137.GA7669@griffis1.net
\r
201 -# highlight the sketchy id parsing; this should be last
\r
202 -+g -- id:foo and bar
\r
203 +# valid id, but warning about missing message
\r
204 ++e id:missing_message_id
\r
206 ++e -- id:some)stuff
\r
207 ++e -- id:some stuff
\r
208 ++e -- id:some"stuff
\r
209 ++e -- id:"a_message_id_with""_a_quote"
\r
210 ++e -- id:"a message id with spaces"
\r
211 ++e -- id:an_id_with_leading_and_trailing_ws \
\r
215 cat <<EOF > EXPECTED
\r
216 -Warning: unsupported query: a
\r
217 +Warning: cannot parse query: a (skipping)
\r
218 Warning: no query string [+0]
\r
219 Warning: no query string [+a +b]
\r
220 Warning: missing query string [+a +b ]
\r
221 Warning: no query string after -- [+c +d --]
\r
222 Warning: hex decoding of tag %zz failed [+%zz -- id:whatever]
\r
223 -Warning: hex decoding of query id:%yy failed [+e +f id:%yy]
\r
224 -Warning: cannot apply tags to missing message: foo and bar
\r
225 +Warning: cannot parse query: id:" (skipping)
\r
226 +Warning: not an id query: tag:abc (skipping)
\r
227 +Warning: cannot apply tags to missing message: missing_message_id
\r
228 +Warning: cannot parse query: id:some)stuff (skipping)
\r
229 +Warning: cannot parse query: id:some stuff (skipping)
\r
230 +Warning: cannot apply tags to missing message: some"stuff
\r
231 +Warning: cannot apply tags to missing message: a_message_id_with"_a_quote
\r
232 +Warning: cannot apply tags to missing message: a message id with spaces
\r
233 +Warning: cannot apply tags to missing message: an_id_with_leading_and_trailing_ws
\r
236 test_expect_equal_file EXPECTED OUTPUT
\r