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 48D69431FAF
\r
6 for <notmuch@notmuchmail.org>; Sun, 30 Dec 2012 22:43:09 -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 Ndzt8uX1o5uJ for <notmuch@notmuchmail.org>;
\r
16 Sun, 30 Dec 2012 22:43:07 -0800 (PST)
\r
17 Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id 04768429E34
\r
20 for <notmuch@notmuchmail.org>; Sun, 30 Dec 2012 22:43:01 -0800 (PST)
\r
21 X-AuditID: 1209190e-b7fa16d000001402-35-50e133f5c5af
\r
22 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])
\r
23 by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 7A.88.05122.5F331E05; Mon, 31 Dec 2012 01:43:01 -0500 (EST)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id qBV6gosg027842;
\r
27 Mon, 31 Dec 2012 01:42:50 -0500
\r
28 Received: from drake.dyndns.org (c-76-21-105-205.hsd1.ca.comcast.net
\r
29 [76.21.105.205]) (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 qBV6gkSg009882
\r
32 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
33 Mon, 31 Dec 2012 01:42:49 -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 1TpZ5C-0000il-6B; Mon, 31 Dec 2012 01:42:46 -0500
\r
37 From: Austin Clements <amdragon@MIT.EDU>
\r
38 To: notmuch@notmuchmail.org
\r
39 Subject: [PATCH v4 4/5] dump/restore: Use Xapian queries for batch-tag format
\r
40 Date: Mon, 31 Dec 2012 01:42:41 -0500
\r
41 Message-Id: <1356936162-2589-5-git-send-email-amdragon@mit.edu>
\r
42 X-Mailer: git-send-email 1.7.10.4
\r
43 In-Reply-To: <1356936162-2589-1-git-send-email-amdragon@mit.edu>
\r
44 References: <1356936162-2589-1-git-send-email-amdragon@mit.edu>
\r
45 X-Brightmail-Tracker:
\r
46 H4sIAAAAAAAAA+NgFrrJIsWRmVeSWpSXmKPExsUixG6novvV+GGAwYWP8hY3WrsZLZqmO1us
\r
47 nstjcf3mTGaLNyvnsTqweuycdZfd4/DXhSwet+6/Zvd4tuoWs8eWQ++ZA1ijuGxSUnMyy1KL
\r
48 9O0SuDImzVrEWjBRveLgvW/MDYw75boYOTgkBEwkFn907GLkBDLFJC7cW8/WxcjFISSwj1Hi
\r
49 6L67jBDOBkaJxo6t7CBVQgIXmSS+7UyFSMxllNi36DpYgk1AQ2Lb/uWMILaIgLTEzruzWUGK
\r
50 mAWaGCWubZrLBpIQFvCV6F32gBnEZhFQlWjafZkVxOYVsJd4P6uRBeIORYnuZxPA6jkFHCR2
\r
51 PpvFArHZXmL33vOMExj5FzAyrGKUTcmt0s1NzMwpTk3WLU5OzMtLLdI11svNLNFLTSndxAgK
\r
52 QU5Jvh2MXw8qHWIU4GBU4uHlYHoYIMSaWFZcmXuIUZKDSUmUVwkYwEJ8SfkplRmJxRnxRaU5
\r
53 qcWHGCU4mJVEeN9qAeV4UxIrq1KL8mFS0hwsSuK8V1Ju+gsJpCeWpGanphakFsFkZTg4lCR4
\r
54 U0CGChalpqdWpGXmlCCkmTg4QYbzAA3PA6nhLS5IzC3OTIfIn2JUlBLnDQFJCIAkMkrz4Hph
\r
55 KeIVozjQK8K8biBVPMD0Atf9CmgwE9BgLYYHIINLEhFSUg2Mlsks30sPnhR+PlViQZhkD7Og
\r
56 RgjTp5fqXxRvfbB8+9tesOzmnYoPic8aOkLKbUritl3Mju8Nu2q87bZPsMTN7+s+WHXynpu4
\r
57 KrNkQ3Hp277M4uPT1CrCNSzP35STi8z1uOu5++Nhj5Wxp8v2cH/VyeWbcIzX81vtyvk9u45a
\r
58 8rVX5SuU/NmgxFKckWioxVxUnAgAZCK7dOwCAAA=
\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: Mon, 31 Dec 2012 06:43:09 -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 | 9 +++++----
\r
87 notmuch-restore.c | 22 ++++++++++------------
\r
88 tag-util.c | 6 ------
\r
89 test/dump-restore | 14 ++++++++------
\r
90 4 files changed, 23 insertions(+), 28 deletions(-)
\r
92 diff --git a/notmuch-dump.c b/notmuch-dump.c
\r
93 index 29d79da..bf01a39 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 @@ -141,13 +142,13 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[])
\r
105 fprintf (stderr, "Error: cannot dump message id containing line break: %s\n", message_id);
\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
111 + if (make_boolean_term (notmuch, "id", message_id,
\r
112 + &buffer, &buffer_size)) {
\r
113 + fprintf (stderr, "Error: failed to quote message id %s\n",
\r
117 - fprintf (output, " -- id:%s\n", buffer);
\r
118 + fprintf (output, " -- %s\n", buffer);
\r
121 notmuch_message_destroy (message);
\r
122 diff --git a/notmuch-restore.c b/notmuch-restore.c
\r
123 index 9ed9b51..77a4c27 100644
\r
124 --- a/notmuch-restore.c
\r
125 +++ b/notmuch-restore.c
\r
126 @@ -207,7 +207,7 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])
\r
127 INTERNAL_ERROR ("compile time constant regex failed.");
\r
130 - char *query_string;
\r
131 + char *query_string, *prefix, *term;
\r
133 if (line_ctx != NULL)
\r
134 talloc_free (line_ctx);
\r
135 @@ -220,19 +220,17 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])
\r
136 &query_string, tag_ops);
\r
139 - if (strncmp ("id:", query_string, 3) != 0) {
\r
140 - fprintf (stderr, "Warning: unsupported query: %s\n", query_string);
\r
141 + ret = parse_boolean_term (line_ctx, query_string,
\r
144 + fprintf (stderr, "Warning: cannot parse query: %s\n",
\r
147 + } else if (strcmp ("id", prefix) != 0) {
\r
148 + fprintf (stderr, "Warning: not an id query: %s\n", query_string);
\r
151 - /* delete id: from front of string; tag_message
\r
152 - * expects a raw message-id.
\r
154 - * XXX: Note that query string id:foo and bar will be
\r
155 - * interpreted as a message id "foo and bar". This
\r
156 - * should eventually be fixed to give a better error
\r
159 - query_string = query_string + 3;
\r
160 + query_string = term;
\r
164 diff --git a/tag-util.c b/tag-util.c
\r
165 index 705b7ba..e4e5dda 100644
\r
168 @@ -124,12 +124,6 @@ parse_tag_line (void *ctx, char *line,
\r
171 /* tok now points to the query string */
\r
172 - if (hex_decode_inplace (tok) != HEX_SUCCESS) {
\r
173 - ret = line_error (TAG_PARSE_INVALID, line_for_error,
\r
174 - "hex decoding of query %s failed", tok);
\r
178 *query_string = tok;
\r
181 diff --git a/test/dump-restore b/test/dump-restore
\r
182 index 6a989b6..f9ae5b3 100755
\r
183 --- a/test/dump-restore
\r
184 +++ b/test/dump-restore
\r
185 @@ -195,23 +195,25 @@ a
\r
187 # the previous line was blank; also no yelling please
\r
188 +%zz -- id:whatever
\r
192 # the next non-comment line should report an an empty tag error for
\r
193 # batch tagging, but not for restore
\r
194 + +e -- id:20091117232137.GA7669@griffis1.net
\r
195 -# highlight the sketchy id parsing; this should be last
\r
196 -+g -- id:foo and bar
\r
197 +# valid id, but warning about missing message
\r
198 ++e id:missing_message_id
\r
201 cat <<EOF > EXPECTED
\r
202 -Warning: unsupported query: a
\r
203 +Warning: cannot parse query: a
\r
204 Warning: no query string [+0]
\r
205 Warning: no query string [+a +b]
\r
206 Warning: missing query string [+a +b ]
\r
207 Warning: no query string after -- [+c +d --]
\r
208 Warning: hex decoding of tag %zz failed [+%zz -- id:whatever]
\r
209 -Warning: hex decoding of query id:%yy failed [+e +f id:%yy]
\r
210 -Warning: cannot apply tags to missing message: foo and bar
\r
211 +Warning: cannot parse query: id:"
\r
212 +Warning: not an id query: tag:abc
\r
213 +Warning: cannot apply tags to missing message: missing_message_id
\r
216 test_expect_equal_file EXPECTED OUTPUT
\r