From 036c0f3f4f17d091556dfc26bee5aa3a29f7912a Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Tue, 25 May 2021 13:51:51 -0400 Subject: Don't depend on List-Archive lore header The newer version of public-inbox is not injecting its own List-Archive headers, so stop relying on it for any purpose. Signed-off-by: Konstantin Ryabitsev --- b4/mbox.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'b4/mbox.py') diff --git a/b4/mbox.py b/b4/mbox.py index bf1a586..f575f94 100644 --- a/b4/mbox.py +++ b/b4/mbox.py @@ -387,7 +387,8 @@ def save_as_quilt(am_msgs, q_dirname): sfh.write('%s\n' % patch_filename) -def get_extra_series(msgs: list, direction: int = 1, wantvers: Optional[int] = None, nocache: bool = False) -> list: +def get_extra_series(msgs: list, direction: int = 1, wantvers: Optional[int] = None, nocache: bool = False, + useproject: Optional[str] = None) -> list: base_msg = None latest_revision = None seen_msgids = set() @@ -427,7 +428,21 @@ def get_extra_series(msgs: list, direction: int = 1, wantvers: Optional[int] = N logger.debug('Could not find cover of 1st patch in mbox') return msgs - listarc = base_msg.get_all('List-Archive')[-1].strip('<>') + config = b4.get_main_config() + loc = urllib.parse.urlparse(config['midmask']) + if not useproject: + projects = b4.get_lore_projects_from_msg(base_msg) + if not projects: + logger.info('Unable to figure out list archive location') + return msgs + useproject = projects[0] + + listarc = '%s://%s/%s/' % (loc.scheme, loc.netloc, useproject) + + if not listarc: + logger.info('Unable to figure out list archive location') + return msgs + nt_msgs = list() if len(obsoleted): for nt_msgid in obsoleted: @@ -601,7 +616,7 @@ def main(cmdargs): return if len(msgs) and cmdargs.checknewer: - msgs = get_extra_series(msgs, direction=1) + msgs = get_extra_series(msgs, direction=1, useproject=cmdargs.useproject) if cmdargs.subcmd == 'am': make_am(msgs, cmdargs, msgid) -- cgit v1.2.3