diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-04-10 16:26:41 -0400 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-04-10 16:26:41 -0400 |
commit | bafb9559e74fdf3246b76f3f765c6783406804e8 (patch) | |
tree | f97c7b3c0b25bc34715fc769b32bede38c45ae5a | |
parent | d33785a01eef60cbb6d509a8f25918137c86e925 (diff) | |
download | b4-bafb9559e74fdf3246b76f3f765c6783406804e8.tar.gz |
Backport improvements to strict thread saving
Do a better job saving a strict thread when the cover letter is in the
middle of the mailbox instead of at the very beginning.
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r-- | b4/__init__.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/b4/__init__.py b/b4/__init__.py index e947b44..eba06cb 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -1365,20 +1365,27 @@ def save_strict_thread(in_mbx, out_mbx, msgid): want = {msgid} got = set() seen = set() + maybe = dict() while True: for msg in in_mbx: c_msgid = LoreMessage.get_clean_msgid(msg) seen.add(c_msgid) if c_msgid in got: continue + logger.debug('Looking at: %s', c_msgid) - refs = list() + refs = set() for ref in msg.get('References', msg.get('In-Reply-To', '')).split(): ref = ref.strip().strip('<>') if ref in got or ref in want: want.add(c_msgid) elif len(ref): - refs.append(ref) + refs.add(ref) + if c_msgid not in want: + if ref not in maybe: + maybe[ref] = set() + logger.debug('Going into maybe: %s->%s', ref, c_msgid) + maybe[ref].add(c_msgid) if c_msgid in want: out_mbx.add(msg) @@ -1386,10 +1393,14 @@ def save_strict_thread(in_mbx, out_mbx, msgid): want.update(refs) want.discard(c_msgid) logger.debug('Kept in thread: %s', c_msgid) + if c_msgid in maybe: + # Add all these to want + want.update(maybe[c_msgid]) + maybe.pop(c_msgid) # Remove any entries not in "seen" (missing messages) for c_msgid in set(want): - if c_msgid not in seen: + if c_msgid not in seen or c_msgid in got: want.remove(c_msgid) if not len(want): break |