summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-06-08 13:55:22 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-06-08 13:55:22 -0400
commitc784afbdbed77155dd90904809003c90e9b43e76 (patch)
tree545e35bee2343d0cfeb7997bb2286985b595b4f5
parentc15b77e0eb0a7939aea61019aa066d0ce97c66ec (diff)
downloadb4-c784afbdbed77155dd90904809003c90e9b43e76.tar.gz
Fix bug with threading when cover ref is missing
When the cover letter is missing and we're starting in the middle of the thread, do not discard messages in the mbox that come before the msgid that we want. Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r--b4/__init__.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/b4/__init__.py b/b4/__init__.py
index fe0a8a1..06bc33e 100644
--- a/b4/__init__.py
+++ b/b4/__init__.py
@@ -1928,8 +1928,12 @@ def save_strict_thread(in_mbx, out_mbx, msgid):
logger.debug('Looking at: %s', c_msgid)
refs = set()
- for ref in msg.get('References', msg.get('In-Reply-To', '')).split():
- ref = ref.strip().strip('<>')
+ msgrefs = list()
+ if msg.get('In-Reply-To', None):
+ msgrefs += email.utils.getaddresses([str(x) for x in msg.get_all('in-reply-to', [])])
+ if msg.get('References', None):
+ msgrefs += email.utils.getaddresses([str(x) for x in msg.get_all('references', [])])
+ for ref in set([x[1] for x in msgrefs]):
if ref in got or ref in want:
want.add(c_msgid)
elif len(ref):
@@ -1950,6 +1954,11 @@ def save_strict_thread(in_mbx, out_mbx, msgid):
# Add all these to want
want.update(maybe[c_msgid])
maybe.pop(c_msgid)
+ # Add all maybes that have the same ref into want
+ for ref in refs:
+ if ref in maybe:
+ want.update(maybe[ref])
+ maybe.pop(ref)
# Remove any entries not in "seen" (missing messages)
for c_msgid in set(want):