From mboxrd@z Thu Jan 1 00:00:00 1970 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 2BD5EC35257 for ; Fri, 2 Oct 2020 23:29:58 +0000 (UTC) Received: by mail.kernel.org (Postfix) id 0DE7E2074B; Fri, 2 Oct 2020 23:29:58 +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 C16CE2072E for ; Fri, 2 Oct 2020 23:29:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601681398; bh=F9poDRdo8pCfpxXCSkGRK30W9FooZKsMHDAPb79Wrp0=; h=From:List-Id:To:Subject:Date:In-Reply-To:References:From; b=dK6gPMqyijpbYsjPjkOZB8f4INkxP1IAdgOLUpiXhas0gN0vOK+gOly2KbDvDEsw7 s96fS47Nt3yveIbKZRjdZ+iCHp34sqtIf3zMp6VGp05MYNwXpsX7w5XVz5vyAjRn2w AsDM6g5IQLL+jZkFGnJxAA4urHYzM2vkS8/+Werk= From: Konstantin Ryabitsev List-Id: To: signatures@kernel.org Subject: [PATCH 10/10] Fix some cherry-picking corner cases Date: Fri, 2 Oct 2020 19:29:15 -0400 Message-Id: <20201002232915.1728301-11-konstantin@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201002232915.1728301-1-konstantin@linuxfoundation.org> References: <20201002232915.1728301-1-konstantin@linuxfoundation.org> 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=iHUEABYIAB0WIQR2vl2yUnHhSB5njDW2xBzjVmSZbAUCX3e38gAKCRC2xBzjVmSZbOv7AP45eGJ +NMVM/sNN6chUuDzWtgKBVFFwbfXUtByKwe/f6wD+NJl44xz67Gc4cYa4li8FLxW2nnUS9PqHdKbD Q/w9SQE= 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