1 Return-Path: <bremner@tethera.net>
\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 91CDB431FAF
\r
6 for <notmuch@notmuchmail.org>; Sat, 8 Dec 2012 14:57:39 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\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 t73LyGzJ4O22 for <notmuch@notmuchmail.org>;
\r
16 Sat, 8 Dec 2012 14:57:38 -0800 (PST)
\r
17 Received: from tesseract.cs.unb.ca (tesseract.cs.unb.ca [131.202.240.238])
\r
18 (using TLSv1 with cipher AES256-SHA (256/256 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 8F83B431FAE
\r
21 for <notmuch@notmuchmail.org>; Sat, 8 Dec 2012 14:57:38 -0800 (PST)
\r
22 Received: from fctnnbsc30w-142167090129.dhcp-dynamic.fibreop.nb.bellaliant.net
\r
23 ([142.167.90.129] helo=zancas.localnet)
\r
24 by tesseract.cs.unb.ca with esmtpsa
\r
25 (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72)
\r
26 (envelope-from <bremner@tethera.net>) id 1ThTKw-00066a-QB
\r
27 for notmuch@notmuchmail.org; Sat, 08 Dec 2012 18:57:35 -0400
\r
28 Received: from bremner by zancas.localnet with local (Exim 4.80)
\r
29 (envelope-from <bremner@tethera.net>) id 1ThTKr-0000qI-3W
\r
30 for notmuch@notmuchmail.org; Sat, 08 Dec 2012 18:57:29 -0400
\r
31 From: david@tethera.net
\r
32 To: notmuch@notmuchmail.org
\r
33 Subject: v5 of Batch-tag dump/restore patches
\r
34 Date: Sat, 8 Dec 2012 18:56:50 -0400
\r
35 Message-Id: <1355007421-3069-1-git-send-email-david@tethera.net>
\r
36 X-Mailer: git-send-email 1.7.10.4
\r
38 X-BeenThere: notmuch@notmuchmail.org
\r
39 X-Mailman-Version: 2.1.13
\r
41 List-Id: "Use and development of the notmuch mail system."
\r
42 <notmuch.notmuchmail.org>
\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
44 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
46 List-Post: <mailto:notmuch@notmuchmail.org>
\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
49 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
50 X-List-Received-Date: Sat, 08 Dec 2012 22:57:39 -0000
\r
52 Yet another version. Luckily we all use threaded mailreaders, right?
\r
56 id:1354979276-20099-1-git-send-email-david@tethera.net
\r
58 One trivial new patch
\r
60 [Patch v5 06/11] notmuch-restore: normalize case of error messages.
\r
62 And a fairly extensive reworking of the error reporting in
\r
63 parse_tag_line. This version introduces an enum for return values of
\r
64 parse_tag_line; this could in the future also be used for
\r
68 commit 55f38bbd034bf8bfbe126cd598cf6085f5f30bf1
\r
69 Author: David Bremner <bremner@debian.org>
\r
70 Date: Sat Dec 8 17:47:21 2012 -0400
\r
72 tag-util.h: add enum for tag parse status
\r
74 diff --git a/tag-util.h b/tag-util.h
\r
75 index 581207a..e828992 100644
\r
78 @@ -30,6 +30,23 @@ typedef enum {
\r
82 +/* These should obey the convention that fatal errors are negative,
\r
83 + * skipped lines are positive.
\r
86 + TAG_PARSE_OUT_OF_MEMORY = -1,
\r
88 + /* Line parsed successfuly. */
\r
89 + TAG_PARSE_SUCCESS = 0,
\r
91 + /* Line has a syntax error */
\r
92 + TAG_PARSE_INVALID = 1,
\r
94 + /* Line was blank or a comment */
\r
95 + TAG_PARSE_SKIPPED = 2
\r
97 +} tag_parse_status_t;
\r
99 /* Parse a string of the following format:
\r
101 * +<tag>|-<tag> [...] [--] <search-terms>
\r
102 @@ -45,16 +62,12 @@ typedef enum {
\r
103 * Leading and trailing space ' ' is ignored. Empty lines and lines
\r
104 * beginning with '#' are ignored.
\r
107 - * 1 skipped (invalid) line
\r
108 - * 2 skipped (valid) line
\r
109 - * -1 fatal(ish) error.
\r
111 * Output Parameters:
\r
112 * ops contains a list of tag operations
\r
113 * query_str the search terms.
\r
116 +tag_parse_status_t
\r
117 parse_tag_line (void *ctx, char *line,
\r
118 tag_op_flag_t flags,
\r
119 char **query_str, tag_op_list_t *ops);
\r
121 commit da6f5cb79c526b8229fb2dbda0ecdce568c2a47c
\r
122 Author: David Bremner <bremner@debian.org>
\r
123 Date: Sat Dec 8 17:48:02 2012 -0400
\r
125 tag-util.h: uncrustify comments
\r
127 diff --git a/tag-util.h b/tag-util.h
\r
128 index e828992..99b0fa0 100644
\r
131 @@ -20,7 +20,7 @@ typedef enum {
\r
133 /* Don't try to avoid database operations. Useful when we
\r
134 * know that message passed needs these operations.
\r
137 TAG_FLAG_PRE_OPTIMIZED = (1 << 2),
\r
139 /* Accept strange tags that might be user error;
\r
140 @@ -118,9 +118,9 @@ void
\r
141 tag_op_list_reset (tag_op_list_t *list);
\r
145 - * return the i'th tag in the list
\r
148 + * return the i'th tag in the list
\r
152 tag_op_list_tag (const tag_op_list_t *list, size_t i);
\r
154 commit e8b27272340c4ba869f1d39e3264f78368d51d86
\r
155 Author: David Bremner <bremner@debian.org>
\r
156 Date: Sat Dec 8 17:53:53 2012 -0400
\r
158 fixup for error message test
\r
160 diff --git a/test/dump-restore b/test/dump-restore
\r
161 index b267792..8a86782 100755
\r
162 --- a/test/dump-restore
\r
163 +++ b/test/dump-restore
\r
164 @@ -183,7 +183,13 @@ test_expect_equal_file EXPECTED.$test_count OUTPUT.$test_count
\r
166 test_begin_subtest 'restore: checking error messages'
\r
167 notmuch restore <<EOF 2>OUTPUT
\r
168 +# the next line has a space
\r
173 +# trailing whitespace
\r
176 # this is a harmless comment, do not yell about it.
\r
178 @@ -197,15 +203,14 @@ notmuch restore <<EOF 2>OUTPUT
\r
181 cat <<EOF > EXPECTED
\r
182 -Warning: no query string: +a +b
\r
183 -Warning: Ignoring invalid input line +a +b
\r
184 -Warning: no query string: +c +d --
\r
185 -Warning: Ignoring invalid input line +c +d --
\r
186 -Warning: Hex decoding of tag %zz failed
\r
187 -Warning: Ignoring invalid input line +%zz -- id:whatever
\r
188 -Warning: Hex decoding of query id:%yy failed
\r
189 -Warning: Ignoring invalid input line +e +f id:%yy
\r
190 -Warning: Cannot apply tags to missing message: foo and bar
\r
191 +Warning: unsupported query: a
\r
192 +Warning: no query string [+0]
\r
193 +Warning: no query string [+a +b]
\r
194 +Warning: missing query string [+a +b ]
\r
195 +Warning: no query string after -- [+c +d --]
\r
196 +Warning: hex decoding of tag %zz failed [+%zz -- id:whatever]
\r
197 +Warning: hex decoding of query id:%yy failed [+e +f id:%yy]
\r
198 +Warning: cannot apply tags to missing message: foo and bar
\r
201 test_expect_equal_file EXPECTED OUTPUT
\r
203 commit 74287d9f7fdd998932ef95ca5846b9905df19e67
\r
204 Author: David Bremner <bremner@debian.org>
\r
205 Date: Sat Dec 8 17:57:10 2012 -0400
\r
207 notmuch-restore: normalize case of error messages.
\r
209 In English, (unlike German) one does not capitalize the first word
\r
212 diff --git a/notmuch-restore.c b/notmuch-restore.c
\r
213 index 44bf88d..dba882b 100644
\r
214 --- a/notmuch-restore.c
\r
215 +++ b/notmuch-restore.c
\r
216 @@ -39,7 +39,7 @@ tag_message (unused (void *ctx),
\r
218 status = notmuch_database_find_message (notmuch, message_id, &message);
\r
219 if (status || message == NULL) {
\r
220 - fprintf (stderr, "Warning: Cannot apply tags to %smessage: %s\n",
\r
221 + fprintf (stderr, "Warning: cannot apply tags to %smessage: %s\n",
\r
222 message ? "" : "missing ", message_id);
\r
224 fprintf (stderr, "%s\n", notmuch_status_to_string (status));
\r
225 @@ -214,7 +214,7 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])
\r
228 if (strncmp ("id:", query_string, 3) != 0) {
\r
229 - fprintf (stderr, "Unsupported query: %s\n", query_string);
\r
230 + fprintf (stderr, "Warning: unsupported query: %s\n", query_string);
\r
233 /* delete id: from front of string; tag_message
\r
235 commit b9d76086b9ca30019dc829b1a106d3f4743cbeb7
\r
236 Author: David Bremner <bremner@debian.org>
\r
237 Date: Sat Dec 8 18:02:26 2012 -0400
\r
239 tag-util.c: refactor error handling.
\r
241 diff --git a/tag-util.c b/tag-util.c
\r
242 index b68ea50..e7233ab 100644
\r
245 @@ -16,6 +16,21 @@ struct _tag_op_list_t {
\r
250 +line_error (tag_parse_status_t status,
\r
251 + const char *line,
\r
252 + const char *format, ...)
\r
256 + va_start (va_args, format);
\r
258 + fprintf (stderr, status < 0 ? "Error: " : "Warning: ");
\r
259 + vfprintf (stderr, format, va_args);
\r
260 + fprintf (stderr, " [%s]\n", line);
\r
265 parse_tag_line (void *ctx, char *line,
\r
266 tag_op_flag_t flags,
\r
267 @@ -55,8 +70,11 @@ parse_tag_line (void *ctx, char *line,
\r
268 /* Optional explicit end of tags marker. */
\r
269 if (tok_len == 2 && strncmp (tok, "--", tok_len) == 0) {
\r
270 tok = strtok_len (tok + tok_len, " ", &tok_len);
\r
272 - fprintf (stderr, "Warning: no query string: %s\n", line_for_error);
\r
273 + if (tok == NULL) {
\r
274 + ret = line_error (TAG_PARSE_INVALID, line_for_error,
\r
275 + "no query string after --");
\r
281 @@ -66,8 +84,8 @@ parse_tag_line (void *ctx, char *line,
\r
283 /* If tag is terminated by NUL, there's no query string. */
\r
284 if (*(tok + tok_len) == '\0') {
\r
285 - fprintf (stderr, "Warning: no query string: %s\n", line_for_error);
\r
287 + ret = line_error (TAG_PARSE_INVALID, line_for_error,
\r
288 + "no query string");
\r
292 @@ -79,47 +97,42 @@ parse_tag_line (void *ctx, char *line,
\r
294 /* Maybe refuse empty tags. */
\r
295 if (! (flags & TAG_FLAG_BE_GENEROUS) && *tag == '\0') {
\r
296 - fprintf (stderr, "Warning: empty tag: %s\n", line_for_error);
\r
298 + ret = line_error (TAG_PARSE_INVALID, line_for_error,
\r
304 if (hex_decode_inplace (tag) != HEX_SUCCESS) {
\r
305 - fprintf (stderr, "Warning: Hex decoding of tag %s failed\n",
\r
308 + ret = line_error (TAG_PARSE_INVALID, line_for_error,
\r
309 + "hex decoding of tag %s failed", tag);
\r
313 if (tag_op_list_append (ctx, tag_ops, tag, remove)) {
\r
314 - /* diagnostics already printed */
\r
316 + ret = line_error (TAG_PARSE_OUT_OF_MEMORY, line_for_error,
\r
324 + /* use a different error message for testing */
\r
325 + ret = line_error (TAG_PARSE_INVALID, line_for_error,
\r
326 + "missing query string");
\r
330 /* tok now points to the query string */
\r
331 if (hex_decode_inplace (tok) != HEX_SUCCESS) {
\r
332 - fprintf (stderr, "Warning: Hex decoding of query %s failed\n",
\r
335 + ret = line_error (TAG_PARSE_INVALID, line_for_error,
\r
336 + "hex decoding of query %s failed", tok);
\r
340 *query_string = tok;
\r
343 - if ((ret % 2) != 0)
\r
344 - fprintf (stderr, "%s invalid input line %s\n",
\r
345 - ret == 1 ? "Warning: Ignoring" : "Error: Failing at",
\r
348 talloc_free (line_for_error);
\r