aboutsummaryrefslogtreecommitdiff
path: root/b4/__init__.py
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2021-05-20 18:02:29 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2021-05-20 18:02:29 -0400
commit3a07935e20c0ae3ff6cce31579b596abfcab21c8 (patch)
treeb85d9ae1aeb6d5069fbce306e3b7fa4d87fe2b11 /b4/__init__.py
parent25d22726f626a9957d0a420fe46c530cbcb0dd60 (diff)
downloadb4-3a07935e20c0ae3ff6cce31579b596abfcab21c8.tar.gz
Reimplement single-msgid cherrypicking
When processing -P_, filter by that msgid (and its follow-ups) early on, instead of parsing the entire thread and only then looking for matches. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Diffstat (limited to 'b4/__init__.py')
-rw-r--r--b4/__init__.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/b4/__init__.py b/b4/__init__.py
index 0053b9c..fc79e7f 100644
--- a/b4/__init__.py
+++ b/b4/__init__.py
@@ -2108,7 +2108,7 @@ def get_pi_thread_by_url(t_mbx_url, nocache=False):
return msgs
-def get_pi_thread_by_msgid(msgid, useproject=None, nocache=False):
+def get_pi_thread_by_msgid(msgid, useproject=None, nocache=False, onlymsgids: Optional[set] = None):
qmsgid = urllib.parse.quote_plus(msgid)
config = get_main_config()
# Grab the head from lore, to see where we are redirected
@@ -2134,7 +2134,18 @@ def get_pi_thread_by_msgid(msgid, useproject=None, nocache=False):
if not msgs:
return None
- strict = get_strict_thread(msgs, msgid)
+ if onlymsgids:
+ strict = list()
+ for msg in msgs:
+ if LoreMessage.get_clean_msgid(msg) in onlymsgids:
+ strict.append(msg)
+ # also grab any messages where this msgid is in the references header
+ for onlymsgid in onlymsgids:
+ if msg.get('references', '').find(onlymsgid) >= 0:
+ strict.append(msg)
+ else:
+ strict = get_strict_thread(msgs, msgid)
+
return strict