summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-11-30 17:39:52 -0500
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-11-30 17:39:52 -0500
commit20722ba22162d1ddeae3615b3010b8311dd9cf42 (patch)
treea2f770af2c025114242569a721470a6e75431c43
parent807a4e1c96582968b722072dab28abf9fc1dc873 (diff)
downloadb4-20722ba22162d1ddeae3615b3010b8311dd9cf42.tar.gz
If using -m, reduce local mbox to strict thread
When passing a local mbox, don't assume that it is going to contain a strict thread already -- it can be just a local mailbox via something like mbsync. This grabs actual thread from the mailbox before looking at individual messages. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r--b4/__init__.py2
-rw-r--r--b4/mbox.py9
2 files changed, 9 insertions, 2 deletions
diff --git a/b4/__init__.py b/b4/__init__.py
index 5c59150..07f2aad 100644
--- a/b4/__init__.py
+++ b/b4/__init__.py
@@ -2206,7 +2206,7 @@ def save_strict_thread(in_mbx, out_mbx, msgid):
return None
if len(in_mbx) > len(out_mbx):
- logger.info('Reduced thread to strict matches only (%s->%s)', len(in_mbx), len(out_mbx))
+ logger.debug('Reduced mbox to strict matches only (%s->%s)', len(in_mbx), len(out_mbx))
def get_pi_thread_by_url(t_mbx_url, savefile, nocache=False):
diff --git a/b4/mbox.py b/b4/mbox.py
index f34b887..e9a2ab2 100644
--- a/b4/mbox.py
+++ b/b4/mbox.py
@@ -511,7 +511,14 @@ def main(cmdargs):
return
else:
if os.path.exists(cmdargs.localmbox):
- threadmbox = cmdargs.localmbox
+ msgid = b4.get_msgid(cmdargs)
+ if os.path.isdir(cmdargs.localmbox):
+ in_mbx = mailbox.Maildir(cmdargs.localmbox)
+ else:
+ in_mbx = mailbox.mbox(cmdargs.localmbox)
+ out_mbx = mailbox.mbox(savefile)
+ b4.save_strict_thread(in_mbx, out_mbx, msgid)
+ threadmbox = savefile
else:
logger.critical('Mailbox %s does not exist', cmdargs.localmbox)
os.unlink(savefile)