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 14:04:20 -0400
commitc8c63b1a31c65cf22ac0bf969c8c66eee6151427 (patch)
tree1530fd5436fea1c969d1d155f29e026ca8fee551
parent31f33fd215590c40a03961580eb33bb1f9616835 (diff)
downloadb4-c8c63b1a31c65cf22ac0bf969c8c66eee6151427.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 cee14f8..79a0c2e 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):