Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09BBBC4363D for ; Fri, 2 Oct 2020 20:20:28 +0000 (UTC) Received: by mail.kernel.org (Postfix) id D48802072E; Fri, 2 Oct 2020 20:20:27 +0000 (UTC) Received: from [192.168.1.64] (unknown [89.36.78.230]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 965DE206FA for ; Fri, 2 Oct 2020 20:20:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601670027; bh=F9poDRdo8pCfpxXCSkGRK30W9FooZKsMHDAPb79Wrp0=; h=From:List-Id:To:Subject:Date:From; b=RdBsMEnXga7wyPul8gLgPV0xQ3KzQeZfu7m7KXmhX0vwzqnA2G8tSr0pcVR3VpqPi dhKw+tgxwTLKZpOudFUFwQy6UgSBJs3mQj76NcAAEEEtvMttyhTdL1oHBStgFgDkgr IfmssJ15x9iBcpbwpeWBm8mjwc3ikW8f1+44NSSg= From: Konstantin Ryabitsev List-Id: To: signatures@kernel.org Subject: [PATCH] Fix some cherry-picking corner cases Date: Fri, 2 Oct 2020 16:20:23 -0400 Message-Id: <20201002202023.1710943-1-konstantin@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patch-Hashes: v=1; h=sha256; g=7ff2560953c28907d17b1c1cd6ea22b72c0ae688; i=LjKnSe5KDCAa8FUuXwYMy3Opxk7PZoscJ+EUkW7y/TU=; m=PC07Aq+mo+E5L3uXu1PuAby9ywrIkWBz9QayNYQ8LmI=; p=CTrMzUH1BAw2ObjTMr8/C45BlK+6cqUmLdjn0FW4MLE= X-Patch-Sig: m=pgp; i=konstantin@linuxfoundation.org; s=0xB6C41CE35664996C; b=iHUEABYIAB0WIQR2vl2yUnHhSB5njDW2xBzjVmSZbAUCX3eLiAAKCRC2xBzjVmSZbBSbAP9MrfW 2M8691ZJ7VLqVhFjw7ku2rSHDrN5o3vM3GcjTygD+MwFR4OH9rTClQJ2myZ40ROkvrQJVOGC5C8fK D4yyywY= Handle several corner cases when trying to cherrypick from incomplete series. Reported-by: Krzysztof Kozlowski Signed-off-by: Konstantin Ryabitsev --- b4/__init__.py | 12 ++++++++---- b4/mbox.py | 20 ++++++++++++-------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/b4/__init__.py b/b4/__init__.py index f0d5d24..dc393a9 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -504,10 +504,14 @@ class LoreSeries: at = 1 atterrors = list() for lmsg in self.patches[1:]: - if cherrypick is not None and at not in cherrypick: - at += 1 - logger.debug(' skipped: [%s/%s] (not in cherrypick)', at, self.expected) - continue + if cherrypick is not None: + if at not in cherrypick: + at += 1 + logger.debug(' skipped: [%s/%s] (not in cherrypick)', at, self.expected) + continue + if lmsg is None: + logger.critical('CRITICAL: [%s/%s] is missing, cannot cherrypick', at, self.expected) + raise KeyError('Cherrypick not in series') if lmsg is not None: if self.has_cover and covertrailers and self.patches[0].followup_trailers: lmsg.followup_trailers += self.patches[0].followup_trailers diff --git a/b4/mbox.py b/b4/mbox.py index 754d0f8..2ec74c9 100644 --- a/b4/mbox.py +++ b/b4/mbox.py @@ -86,12 +86,12 @@ def mbox_to_am(mboxfile, cmdargs): at = 0 for lmsg in lser.patches[1:]: at += 1 - if lmsg.msgid == msgid: + if lmsg and lmsg.msgid == msgid: cherrypick = [at] - cmdargs.cherrypick = '5' + cmdargs.cherrypick = f'<{msgid}>' break if not len(cherrypick): - logger.critical('Specified msgid is not present in the series, cannot cherry-pick') + logger.critical('Specified msgid is not present in the series, cannot cherrypick') sys.exit(1) elif cmdargs.cherrypick.find('*') >= 0: # Globbing on subject @@ -110,10 +110,14 @@ def mbox_to_am(mboxfile, cmdargs): logger.critical('Writing %s', am_filename) mbx = mailbox.mbox(am_filename) - am_mbx = lser.save_am_mbox(mbx, noaddtrailers=cmdargs.noaddtrailers, - covertrailers=covertrailers, trailer_order=config['trailer-order'], - addmysob=cmdargs.addmysob, addlink=cmdargs.addlink, - linkmask=config['linkmask'], cherrypick=cherrypick) + try: + am_mbx = lser.save_am_mbox(mbx, noaddtrailers=cmdargs.noaddtrailers, + covertrailers=covertrailers, trailer_order=config['trailer-order'], + addmysob=cmdargs.addmysob, addlink=cmdargs.addlink, + linkmask=config['linkmask'], cherrypick=cherrypick) + except KeyError: + sys.exit(1) + logger.info('---') if cherrypick is None: @@ -153,7 +157,7 @@ def mbox_to_am(mboxfile, cmdargs): logger.info('Prepared a fake commit range for 3-way merge (%.12s..%.12s)', rstart, rend) logger.critical('---') - if not lser.complete: + if not lser.complete and not cmdargs.cherrypick: logger.critical('WARNING: Thread incomplete!') if lser.has_cover and not cmdargs.nocover: -- 2.26.2