[PATCH 4/4] Update NEWS for user.other_name
[notmuch-archives.git] / 90 / f306841772634191534a31f513d1d6a0e56927
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 18F26431FD2\r
6         for <notmuch@notmuchmail.org>; Mon, 24 Dec 2012 21:58:20 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \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 VjhCfDf3T6RL for <notmuch@notmuchmail.org>;\r
16         Mon, 24 Dec 2012 21:58:18 -0800 (PST)\r
17 Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU\r
18         [18.7.68.36])\r
19         by olra.theworths.org (Postfix) with ESMTP id 61E96431FC0\r
20         for <notmuch@notmuchmail.org>; Mon, 24 Dec 2012 21:58:14 -0800 (PST)\r
21 X-AuditID: 12074424-b7f4e6d0000004ca-2a-50d94076303e\r
22 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
23         by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id 80.FE.01226.67049D05; Tue, 25 Dec 2012 00:58:14 -0500 (EST)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id qBP5wCKx008906; \r
27         Tue, 25 Dec 2012 00:58:12 -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 qBP5w7WY011707\r
32         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
33         Tue, 25 Dec 2012 00:58:10 -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 1TnNWg-0001Xu-RP; Tue, 25 Dec 2012 00:58:06 -0500\r
37 From: Austin Clements <amdragon@MIT.EDU>\r
38 To: notmuch@notmuchmail.org\r
39 Subject: [PATCH 4/5] dump/restore: Use Xapian queries for batch-tag format\r
40 Date: Tue, 25 Dec 2012 00:57:55 -0500\r
41 Message-Id: <1356415076-5692-5-git-send-email-amdragon@mit.edu>\r
42 X-Mailer: git-send-email 1.7.10.4\r
43 In-Reply-To: <1356415076-5692-1-git-send-email-amdragon@mit.edu>\r
44 References: <1356415076-5692-1-git-send-email-amdragon@mit.edu>\r
45 X-Brightmail-Tracker:\r
46  H4sIAAAAAAAAA+NgFjrHIsWRmVeSWpSXmKPExsUixG6nrlvmcDPAYO4/bosbrd2MFk3TnS1W\r
47         z+WxuH5zJrMDi8fOWXfZPW7df83u8WzVLWaPLYfeMwewRHHZpKTmZJalFunbJXBlrJ5wl7Hg\r
48         v2rF91sfmRsY98h2MXJwSAiYSJyamdrFyAlkiklcuLeerYuRi0NIYB+jxKXzl6GcDYwS654f\r
49         YodwLjJJHD84GSozl1Hi8Y+3LCD9bAIaEtv2L2cEsUUEpCV23p3NCmIzC+RJPHy0lR1knbCA\r
50         l8T1GUkgYRYBVYkdp86DtfIK2Eu0/PzCBnGGokT3swlgNqeAg8TcPyvBaoSAar7O3cwygZF/\r
51         ASPDKkbZlNwq3dzEzJzi1GTd4uTEvLzUIl1zvdzMEr3UlNJNjOBgc1HZwdh8SOkQowAHoxIP\r
52         b8HkGwFCrIllxZW5hxglOZiURHlf290MEOJLyk+pzEgszogvKs1JLT7EKMHBrCTCa8IDlONN\r
53         SaysSi3Kh0lJc7AoifNeT7npLySQnliSmp2aWpBaBJOV4eBQkuAttQdqFCxKTU+tSMvMKUFI\r
54         M3FwggznARoeClLDW1yQmFucmQ6RP8WoKCXOWwmSEABJZJTmwfXCksErRnGgV4R5T4NU8QAT\r
55         CVz3K6DBTECDY/lugAwuSURISTUwsgUJpFv4xp1yuMukcFHqRfGf7/4L2KQ3sh6vevDIxrxk\r
56         W8SvxPO7ZyYpZnKdOFnWrOS4eHHrqxs+9z2StvisTvruuYzfKOmf9pQp5j2SYkd1bPeEvpso\r
57         29r1qXNfbfD+s7uqOuMX5mlya6nL/TZPXFIiGLznZNQtNq/Kff/nmRfEu0zs9f6ixFKckWio\r
58         xVxUnAgArX5+tuECAAA=\r
59 X-BeenThere: notmuch@notmuchmail.org\r
60 X-Mailman-Version: 2.1.13\r
61 Precedence: list\r
62 List-Id: "Use and development of the notmuch mail system."\r
63         <notmuch.notmuchmail.org>\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
65         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
67 List-Post: <mailto:notmuch@notmuchmail.org>\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
70         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
71 X-List-Received-Date: Tue, 25 Dec 2012 05:58:20 -0000\r
72 \r
73 This switches the new batch-tag format away from using a home-grown\r
74 hex-encoding scheme for message IDs in the dump to simply using Xapian\r
75 queries with Xapian quoting syntax.\r
76 \r
77 This has a variety of advantages beyond presenting a cleaner and more\r
78 consistent interface.  Foremost is that it will dramatically simplify\r
79 the quoting for batch tagging, which shares the same input format.\r
80 While the hex-encoding is no better or worse for the simple ID queries\r
81 used by dump/restore, it becomes onerous for general-purpose queries\r
82 used in batch tagging.  It also better handles strange cases like\r
83 "id:foo and bar", since this is no longer syntactically valid.\r
84 ---\r
85  notmuch-dump.c    |    9 +++++----\r
86  notmuch-restore.c |   22 ++++++++++------------\r
87  tag-util.c        |    6 ------\r
88  test/dump-restore |   11 +++++------\r
89  4 files changed, 20 insertions(+), 28 deletions(-)\r
90 \r
91 diff --git a/notmuch-dump.c b/notmuch-dump.c\r
92 index 29d79da..bf01a39 100644\r
93 --- a/notmuch-dump.c\r
94 +++ b/notmuch-dump.c\r
95 @@ -20,6 +20,7 @@\r
96  \r
97  #include "notmuch-client.h"\r
98  #include "dump-restore-private.h"\r
99 +#include "string-util.h"\r
100  \r
101  int\r
102  notmuch_dump_command (unused (void *ctx), int argc, char *argv[])\r
103 @@ -141,13 +142,13 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[])\r
104                 fprintf (stderr, "Error: cannot dump message id containing line break: %s\n", message_id);\r
105                 return 1;\r
106             }\r
107 -           if (hex_encode (notmuch, message_id,\r
108 -                           &buffer, &buffer_size) != HEX_SUCCESS) {\r
109 -                   fprintf (stderr, "Error: failed to hex-encode msg-id %s\n",\r
110 +           if (make_boolean_term (notmuch, "id", message_id,\r
111 +                                  &buffer, &buffer_size)) {\r
112 +                   fprintf (stderr, "Error: failed to quote message id %s\n",\r
113                              message_id);\r
114                     return 1;\r
115             }\r
116 -           fprintf (output, " -- id:%s\n", buffer);\r
117 +           fprintf (output, " -- %s\n", buffer);\r
118         }\r
119  \r
120         notmuch_message_destroy (message);\r
121 diff --git a/notmuch-restore.c b/notmuch-restore.c\r
122 index 9ed9b51..77a4c27 100644\r
123 --- a/notmuch-restore.c\r
124 +++ b/notmuch-restore.c\r
125 @@ -207,7 +207,7 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])\r
126             INTERNAL_ERROR ("compile time constant regex failed.");\r
127  \r
128      do {\r
129 -       char *query_string;\r
130 +       char *query_string, *prefix, *term;\r
131  \r
132         if (line_ctx != NULL)\r
133             talloc_free (line_ctx);\r
134 @@ -220,19 +220,17 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])\r
135                                   &query_string, tag_ops);\r
136  \r
137             if (ret == 0) {\r
138 -               if (strncmp ("id:", query_string, 3) != 0) {\r
139 -                   fprintf (stderr, "Warning: unsupported query: %s\n", query_string);\r
140 +               ret = parse_boolean_term (line_ctx, query_string,\r
141 +                                         &prefix, &term);\r
142 +               if (ret) {\r
143 +                   fprintf (stderr, "Warning: cannot parse query: %s\n",\r
144 +                            query_string);\r
145 +                   continue;\r
146 +               } else if (strcmp ("id", prefix) != 0) {\r
147 +                   fprintf (stderr, "Warning: not an id query: %s\n", query_string);\r
148                     continue;\r
149                 }\r
150 -               /* delete id: from front of string; tag_message\r
151 -                * expects a raw message-id.\r
152 -                *\r
153 -                * XXX: Note that query string id:foo and bar will be\r
154 -                * interpreted as a message id "foo and bar". This\r
155 -                * should eventually be fixed to give a better error\r
156 -                * message.\r
157 -                */\r
158 -               query_string = query_string + 3;\r
159 +               query_string = term;\r
160             }\r
161         }\r
162  \r
163 diff --git a/tag-util.c b/tag-util.c\r
164 index 705b7ba..e4e5dda 100644\r
165 --- a/tag-util.c\r
166 +++ b/tag-util.c\r
167 @@ -124,12 +124,6 @@ parse_tag_line (void *ctx, char *line,\r
168      }\r
169  \r
170      /* tok now points to the query string */\r
171 -    if (hex_decode_inplace (tok) != HEX_SUCCESS) {\r
172 -       ret = line_error (TAG_PARSE_INVALID, line_for_error,\r
173 -                         "hex decoding of query %s failed", tok);\r
174 -       goto DONE;\r
175 -    }\r
176 -\r
177      *query_string = tok;\r
178  \r
179    DONE:\r
180 diff --git a/test/dump-restore b/test/dump-restore\r
181 index 6a989b6..aecc393 100755\r
182 --- a/test/dump-restore\r
183 +++ b/test/dump-restore\r
184 @@ -195,23 +195,22 @@ a\r
185  \r
186  # the previous line was blank; also no yelling please\r
187  +%zz -- id:whatever\r
188 -+e +f id:%yy\r
189 ++e +f id:"\r
190 ++e +f tag:abc\r
191  # the next non-comment line should report an an empty tag error for\r
192  # batch tagging, but not for restore\r
193  + +e -- id:20091117232137.GA7669@griffis1.net\r
194 -# highlight the sketchy id parsing; this should be last\r
195 -+g -- id:foo and bar\r
196  EOF\r
197  \r
198  cat <<EOF > EXPECTED\r
199 -Warning: unsupported query: a\r
200 +Warning: cannot parse query: a\r
201  Warning: no query string [+0]\r
202  Warning: no query string [+a +b]\r
203  Warning: missing query string [+a +b ]\r
204  Warning: no query string after -- [+c +d --]\r
205  Warning: hex decoding of tag %zz failed [+%zz -- id:whatever]\r
206 -Warning: hex decoding of query id:%yy failed [+e +f id:%yy]\r
207 -Warning: cannot apply tags to missing message: foo and bar\r
208 +Warning: cannot parse query: id:"\r
209 +Warning: not an id query: tag:abc\r
210  EOF\r
211  \r
212  test_expect_equal_file EXPECTED OUTPUT\r
213 -- \r
214 1.7.10.4\r
215 \r