database error
[notmuch-archives.git] / 3f / 4683e44d0aacdc9464cacd8925b0f0be0f6ecb
1 Return-Path: <markwalters1009@gmail.com>\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 A07E0431FC4\r
6         for <notmuch@notmuchmail.org>; Sat,  3 Mar 2012 05:04:18 -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.201\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
14         RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
15 Received: from olra.theworths.org ([127.0.0.1])\r
16         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
17         with ESMTP id YvGvANPoTskB for <notmuch@notmuchmail.org>;\r
18         Sat,  3 Mar 2012 05:04:16 -0800 (PST)\r
19 Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com\r
20         [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
21         (No client certificate requested)\r
22         by olra.theworths.org (Postfix) with ESMTPS id 84912431FD7\r
23         for <notmuch@notmuchmail.org>; Sat,  3 Mar 2012 05:04:16 -0800 (PST)\r
24 Received: by wico1 with SMTP id o1so697883wic.26\r
25         for <notmuch@notmuchmail.org>; Sat, 03 Mar 2012 05:04:15 -0800 (PST)\r
26 Received-SPF: pass (google.com: domain of markwalters1009@gmail.com designates\r
27         10.216.131.78 as permitted sender) client-ip=10.216.131.78; \r
28 Authentication-Results: mr.google.com; spf=pass (google.com: domain of\r
29         markwalters1009@gmail.com designates 10.216.131.78 as permitted\r
30         sender) smtp.mail=markwalters1009@gmail.com;\r
31         dkim=pass header.i=markwalters1009@gmail.com\r
32 Received: from mr.google.com ([10.216.131.78])\r
33         by 10.216.131.78 with SMTP id l56mr1102683wei.94.1330779855449\r
34         (num_hops = 1); Sat, 03 Mar 2012 05:04:15 -0800 (PST)\r
35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
36         h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
37         bh=VWN20Q6vv7qze+E1bITNO3I0EUFnZyPea5Qvg80VzYc=;\r
38         b=IXwwhJNTzKIxHzZFdCUMLNp8efhzBaAe+qzYlUZesxFKAsY3GCGaTckJK1IFLOmyfu\r
39         ai9HpNhQQuBf+YqOt8Dvyniq0X+7CVmGPulJN0DxGeS42uXQBofJrplyMr2KB0qo4SDQ\r
40         7370cHkxZUWZYTHhoQUcd9/Bca5STnA8gFLD2AJAvxFsEbkz8/5L7X2UhUwfqkuc0vt7\r
41         sirz6o5GoJHmRUKqMeQqifOdiSdiwoiBcnufMTkXn2SVEuPtQ06MJKE6fWgJ78DsYbXf\r
42         ZONoDYGqDY3JLCwqh4W0kd5nm3ZBTGAq7QU+TB2zmoryzU+csAHucQNzPAvzJST/4ptr\r
43         aeDw==\r
44 Received: by 10.216.131.78 with SMTP id l56mr904323wei.94.1330779855388;\r
45         Sat, 03 Mar 2012 05:04:15 -0800 (PST)\r
46 Received: from localhost (94-192-233-223.zone6.bethere.co.uk.\r
47  [94.192.233.223])      by mx.google.com with ESMTPS id\r
48  h19sm9355204wiw.9.2012.03.03.05.04.14  (version=TLSv1/SSLv3 cipher=OTHER);\r
49         Sat, 03 Mar 2012 05:04:14 -0800 (PST)\r
50 From: Mark Walters <markwalters1009@gmail.com>\r
51 To: notmuch@notmuchmail.org\r
52 Subject: [PATCH 3/5] cli: move search to the new --with-excluded naming\r
53  scheme.\r
54 Date: Sat,  3 Mar 2012 13:05:16 +0000\r
55 Message-Id: <1330779918-28024-4-git-send-email-markwalters1009@gmail.com>\r
56 X-Mailer: git-send-email 1.7.2.3\r
57 In-Reply-To: <1330779918-28024-1-git-send-email-markwalters1009@gmail.com>\r
58 References: <1330779918-28024-1-git-send-email-markwalters1009@gmail.com>\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: Sat, 03 Mar 2012 13:04:18 -0000\r
72 \r
73 This commit replaces the --no-exclude option with a --with-excluded\r
74 option. The output is identical in all cases except output-summary. In\r
75 this case they output exactly the same thread lines. They differ in\r
76 that with the new option the match count (i.e., the x in [x/n] in the\r
77 output) is the number of matching non-excluded messages rather than\r
78 the number of matching messages.\r
79 \r
80 It also change the behaviour when the --with-excluded option is not\r
81 set (for output=summary): it no longer returns threads only matching\r
82 in excluded messages. This is neccesary to keep the cli output\r
83 uncluttered and for speed reasons.\r
84 ---\r
85  man/man1/notmuch-search.1 |    6 ++++--\r
86  notmuch-search.c          |   20 +++++++++++---------\r
87  test/search               |    9 ++++-----\r
88  3 files changed, 19 insertions(+), 16 deletions(-)\r
89 \r
90 diff --git a/man/man1/notmuch-search.1 b/man/man1/notmuch-search.1\r
91 index 8426aa3..e46ae68 100644\r
92 --- a/man/man1/notmuch-search.1\r
93 +++ b/man/man1/notmuch-search.1\r
94 @@ -114,9 +114,11 @@ Limit the number of displayed results to N.\r
95  \r
96  .RS 4\r
97  .TP 4\r
98 -.BR \-\-no\-exclude\r
99 +.BR \-\-with\-excluded\r
100  \r
101 -Do not exclude the messages matching search.exclude_tags in the config file.\r
102 +Include messages matching search.exclude_tags from the config file in\r
103 +the output. Note that, in this case, the summary output shows the\r
104 +number of matching non-excluded messages for each thread.\r
105  .RE\r
106  \r
107  .SH SEE ALSO\r
108 diff --git a/notmuch-search.c b/notmuch-search.c\r
109 index f6061e4..4af19b5 100644\r
110 --- a/notmuch-search.c\r
111 +++ b/notmuch-search.c\r
112 @@ -210,9 +210,6 @@ do_search_threads (const search_format_t *format,\r
113      int first_thread = 1;\r
114      int i;\r
115  \r
116 -    if (output == OUTPUT_THREADS)\r
117 -       notmuch_query_set_omit_excluded_messages (query, TRUE);\r
118 -\r
119      if (offset < 0) {\r
120         offset += notmuch_query_count_threads (query);\r
121         if (offset < 0)\r
122 @@ -303,8 +300,6 @@ do_search_messages (const search_format_t *format,\r
123      int first_message = 1;\r
124      int i;\r
125  \r
126 -    notmuch_query_set_omit_excluded_messages (query, TRUE);\r
127 -\r
128      if (offset < 0) {\r
129         offset += notmuch_query_count_messages (query);\r
130         if (offset < 0)\r
131 @@ -376,7 +371,6 @@ do_search_tags (notmuch_database_t *notmuch,\r
132      const char *tag;\r
133      int first_tag = 1;\r
134  \r
135 -    notmuch_query_set_omit_excluded_messages (query, TRUE);\r
136      /* should the following only special case if no excluded terms\r
137       * specified? */\r
138  \r
139 @@ -435,7 +429,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
140      output_t output = OUTPUT_SUMMARY;\r
141      int offset = 0;\r
142      int limit = -1; /* unlimited */\r
143 -    notmuch_bool_t no_exclude = FALSE;\r
144 +    notmuch_bool_t with_excluded = FALSE;\r
145      unsigned int i;\r
146  \r
147      enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT }\r
148 @@ -457,7 +451,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
149                                   { "files", OUTPUT_FILES },\r
150                                   { "tags", OUTPUT_TAGS },\r
151                                   { 0, 0 } } },\r
152 -       { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'd', 0 },\r
153 +       { NOTMUCH_OPT_BOOLEAN, &with_excluded, "with-excluded", 'd', 0 },\r
154         { NOTMUCH_OPT_INT, &offset, "offset", 'O', 0 },\r
155         { NOTMUCH_OPT_INT, &limit, "limit", 'L', 0  },\r
156         { 0, 0, 0, 0, 0 }\r
157 @@ -505,7 +499,13 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
158  \r
159      notmuch_query_set_sort (query, sort);\r
160  \r
161 -    if (!no_exclude) {\r
162 +    /* If we have --with-excluded we could use\r
163 +     * notmuch_query_set_with_excluded, but it is simpler not to set\r
164 +     * the exclude tags in the first place. The one exception is the\r
165 +     * summary output where we do need to use\r
166 +     * notmuch_query_set_with_excluded as we do want the counts to\r
167 +     * reflect the excludes. */\r
168 +    if (!with_excluded || output == OUTPUT_SUMMARY) {\r
169         const char **search_exclude_tags;\r
170         size_t search_exclude_tags_length;\r
171  \r
172 @@ -513,6 +513,8 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
173             (config, &search_exclude_tags_length);\r
174         for (i = 0; i < search_exclude_tags_length; i++)\r
175             notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);\r
176 +       if (output == OUTPUT_SUMMARY && with_excluded)\r
177 +           notmuch_query_set_with_excluded_messages (query, TRUE);\r
178      }\r
179  \r
180      switch (output) {\r
181 diff --git a/test/search b/test/search\r
182 index 081f60c..6d26f56 100755\r
183 --- a/test/search\r
184 +++ b/test/search\r
185 @@ -136,8 +136,7 @@ generate_message '[subject]="Deleted"'\r
186  notmuch new > /dev/null\r
187  notmuch tag +deleted id:$gen_msg_id\r
188  output=$(notmuch search subject:deleted | notmuch_search_sanitize)\r
189 -test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Not deleted (inbox unread)\r
190 -thread:XXX   2001-01-05 [0/1] Notmuch Test Suite; Deleted (deleted inbox unread)"\r
191 +test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Not deleted (inbox unread)"\r
192  \r
193  test_begin_subtest "Exclude \"deleted\" messages from search, overridden"\r
194  output=$(notmuch search subject:deleted and tag:deleted | notmuch_search_sanitize)\r
195 @@ -149,10 +148,10 @@ output=$(notmuch search subject:deleted | notmuch_search_sanitize)\r
196  test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Not deleted (inbox unread)\r
197  thread:XXX   2001-01-05 [1/2] Notmuch Test Suite; Not deleted reply (deleted inbox unread)"\r
198  \r
199 -test_begin_subtest "Don't exclude \"deleted\" messages when --no-exclude specified"\r
200 -output=$(notmuch search --no-exclude subject:deleted | notmuch_search_sanitize)\r
201 +test_begin_subtest "Don't exclude \"deleted\" messages when --with-excluded specified"\r
202 +output=$(notmuch search --with-excluded subject:deleted | notmuch_search_sanitize)\r
203  test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Not deleted (inbox unread)\r
204 -thread:XXX   2001-01-05 [2/2] Notmuch Test Suite; Deleted (deleted inbox unread)"\r
205 +thread:XXX   2001-01-05 [1/2] Notmuch Test Suite; Not deleted reply (deleted inbox unread)"\r
206  \r
207  test_begin_subtest "Don't exclude \"deleted\" messages from search if not configured"\r
208  notmuch config set search.exclude_tags\r
209 -- \r
210 1.7.2.3\r
211 \r