Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 5a / 6a0e7acef0908eba5dceef32ef97ec762935bf
1 Return-Path: <dkg@fifthhorseman.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 arlo.cworth.org (Postfix) with ESMTP id DF5F36DE00DF\r
6  for <notmuch@notmuchmail.org>; Sat,  2 Apr 2016 07:16:03 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.366\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.366 tagged_above=-999 required=5\r
12  tests=[AWL=-0.366] autolearn=disabled\r
13 Received: from arlo.cworth.org ([127.0.0.1])\r
14  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
15  with ESMTP id jaxV78kiAT08 for <notmuch@notmuchmail.org>;\r
16  Sat,  2 Apr 2016 07:15:56 -0700 (PDT)\r
17 Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108])\r
18  by arlo.cworth.org (Postfix) with ESMTP id DACF16DE02D4\r
19  for <notmuch@notmuchmail.org>; Sat,  2 Apr 2016 07:15:47 -0700 (PDT)\r
20 Received: from fifthhorseman.net (dhcp-a244.meeting.ietf.org [31.133.162.68])\r
21  by che.mayfirst.org (Postfix) with ESMTPSA id 8C0A8F99B\r
22  for <notmuch@notmuchmail.org>; Sat,  2 Apr 2016 10:15:45 -0400 (EDT)\r
23 Received: by fifthhorseman.net (Postfix, from userid 1000)\r
24  id A291520843; Sat,  2 Apr 2016 11:15:41 -0300 (BRT)\r
25 From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
26 To: Notmuch Mail <notmuch@notmuchmail.org>\r
27 Subject: [PATCH v2 1/7] test thread breakage when messages are removed and\r
28  re-added\r
29 Date: Sat,  2 Apr 2016 11:15:35 -0300\r
30 Message-Id: <1459606541-23889-1-git-send-email-dkg@fifthhorseman.net>\r
31 X-Mailer: git-send-email 2.8.0.rc3\r
32 In-Reply-To: <1459445693-3900-1-git-send-email-dkg@fifthhorseman.net>\r
33 References: <1459445693-3900-1-git-send-email-dkg@fifthhorseman.net>\r
34 X-BeenThere: notmuch@notmuchmail.org\r
35 X-Mailman-Version: 2.1.20\r
36 Precedence: list\r
37 List-Id: "Use and development of the notmuch mail system."\r
38  <notmuch.notmuchmail.org>\r
39 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
40  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
41 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
42 List-Post: <mailto:notmuch@notmuchmail.org>\r
43 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
44 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
45  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
46 X-List-Received-Date: Sat, 02 Apr 2016 14:16:04 -0000\r
47 \r
48 This test (T590-thread-breakage.sh) currently fails!\r
49 \r
50 If you have a two-message thread where message "B" is in-reply-to "A",\r
51 notmuch rightly sees this as a single thread.\r
52 \r
53 But if you:\r
54 \r
55  * remove "A" from the message store\r
56  * run "notmuch new"\r
57  * add "A" back into the message store\r
58  * re-run "notmuch new"\r
59 \r
60 Then notmuch sees the messages as distinct threads.\r
61 \r
62 I think this happens because if you insert "B" initially (before\r
63 anything is known about "A"), then a "ghost message" gets added to the\r
64 database in reference to "A" that is in the same thread, which "A"\r
65 takes over when it appears.\r
66 \r
67 But if "A" is subsequently removed, no ghost message is retained, so\r
68 when "A" appears, it is treated as a new thread.\r
69 \r
70 I don't know how to easily fix this, but i see a few options:\r
71 \r
72 ghost-on-removal\r
73 ----------------\r
74 \r
75 We could unilaterally add a ghost upon message removal.  This has a\r
76 few disadvantages: the message index would leak information about what\r
77 messages the user has ever been exposed to, and we also create a\r
78 perpetually-growing dataset -- the ghosts can never be removed.\r
79 \r
80 ghost-on-removal-when-shared-thread-exists\r
81 ------------------------------------------\r
82 \r
83 We could add a ghost upon message removal iff there are other\r
84 non-ghost messages with the same thread ID.\r
85 \r
86 We'd also need to remove all ghost messages that share a thread when\r
87 the last non-ghost message in that thread is removed.\r
88 \r
89 This still has a bit of information leakage, though: the message index\r
90 would reveal that i've seen a newer message in a thread, even if i had\r
91 deleted it from my message store\r
92 \r
93 track-dependencies\r
94 ------------------\r
95 \r
96 rather than a simple "ghost-message" we could store all the (A,B)\r
97 message-reference pairs internally, showing which messages A reference\r
98 which other messages B.\r
99 \r
100 Then removal of message X would require deleting all message-reference\r
101 pairs (X,B), and only deleting a ghost message if no (A,X) reference\r
102 pair exists.\r
103 \r
104 This requires modifying the database by adding a new and fairly weird\r
105 table that would need to be indexed by both columns.  I don't know\r
106 whether xapian has nice ways to do that.\r
107 \r
108 scan-dependencies\r
109 -----------------\r
110 \r
111 Without modifying the database, we could do something less efficient.\r
112 \r
113 Upon removal of message X, we could scan the headers of all non-ghost\r
114 messages that share a thread with X.  If any of those messages refers\r
115 to X, we would add a ghost message.  If none of them do, then we would\r
116 just drop X entirely from the table.\r
117 ---\r
118  test/T590-thread-breakage.sh | 63 ++++++++++++++++++++++++++++++++++++++++++++\r
119  1 file changed, 63 insertions(+)\r
120  create mode 100755 test/T590-thread-breakage.sh\r
121 \r
122 diff --git a/test/T590-thread-breakage.sh b/test/T590-thread-breakage.sh\r
123 new file mode 100755\r
124 index 0000000..704f504\r
125 --- /dev/null\r
126 +++ b/test/T590-thread-breakage.sh\r
127 @@ -0,0 +1,63 @@\r
128 +#!/usr/bin/env bash\r
129 +#\r
130 +# Copyright (c) 2016 Daniel Kahn Gillmor\r
131 +#\r
132 +\r
133 +test_description='thread breakage by reindexing (currently broken)'\r
134 +\r
135 +. ./test-lib.sh || exit 1\r
136 +\r
137 +message_a() {\r
138 +    mkdir -p ${MAIL_DIR}/cur\r
139 +    cat > ${MAIL_DIR}/cur/a <<EOF\r
140 +Subject: First message\r
141 +Message-ID: <a@example.net>\r
142 +From: Alice <alice@example.net>\r
143 +To: Bob <bob@example.net>\r
144 +Date: Thu, 31 Mar 2016 20:10:00 -0400\r
145 +\r
146 +This is the first message in the thread.\r
147 +EOF\r
148 +}\r
149 +\r
150 +message_b() {\r
151 +    mkdir -p ${MAIL_DIR}/cur\r
152 +    cat > ${MAIL_DIR}/cur/b <<EOF\r
153 +Subject: Second message\r
154 +Message-ID: <b@example.net>\r
155 +In-Reply-To: <a@example.net>\r
156 +References: <a@example.net>\r
157 +From: Bob <bob@example.net>\r
158 +To: Alice <alice@example.net>\r
159 +Date: Thu, 31 Mar 2016 20:15:00 -0400\r
160 +\r
161 +This is the second message in the thread.\r
162 +EOF\r
163 +}\r
164 +\r
165 +\r
166 +test_thread_count() {\r
167 +    notmuch new >/dev/null\r
168 +    test_begin_subtest "${2:-Expecting $1 thread(s)}"\r
169 +    count=$(notmuch count --output=threads)\r
170 +    test_expect_equal "$count" "$1"\r
171 +}\r
172 +\r
173 +test_thread_count 0 'There should be no threads initially'\r
174 +\r
175 +message_a\r
176 +test_thread_count 1 'One message in: one thread'\r
177 +\r
178 +message_b\r
179 +test_thread_count 1 'Second message in the same thread: one thread'\r
180 +\r
181 +rm -f ${MAIL_DIR}/cur/a\r
182 +test_thread_count 1 'First message removed: still only one thread'\r
183 +\r
184 +message_a\r
185 +# this is known to fail (it shows 2 threads) because no "ghost\r
186 +# message" was created for message A when it was removed from the\r
187 +# index, despite message B still pointing to it.\r
188 +test_thread_count 1 'First message reappears: should return to the same thread'\r
189 +\r
190 +test_done\r
191 -- \r
192 2.8.0.rc3\r
193 \r