From patchwork Sat Apr 15 19:30:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain X-Patchwork-Id: 13212634 Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B0CA7498 for ; Sat, 15 Apr 2023 19:31:20 +0000 (UTC) Received: by mail-qv1-f53.google.com with SMTP id dw2so30737156qvb.11 for ; Sat, 15 Apr 2023 12:31:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681587080; x=1684179080; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Irete0T3ybMRlZOJLSsPU9NSiuY7uU8U7nsV28q8Ztk=; b=YVg2o3VHh+x6cABfeKjSAUUfBfiQYYqZ059CmD//gGLqdbQXdnuInuiNCL+bbJYVN0 O5UstyN5cLFTAD9SO8BcH4jg1mno3REGvMzBowh7ZklexsSqJq8swgQCsieHVVi6PUc1 Kq7kEeH9pjdjuDAi6RCji4PFjM6Oh49CnEVMr20xh1GO1RcxTPgrp83/eqR0sTN0BVKu i1GPJyTEtJEmC4qjA5E4bQC8kN8CR0rTxVy3PVdNcAsADV0LNJMbvZDKWV+EJU1mBJhy 9jfec8OgZy5m1ot30VNoP8VxRezcsUWrOr6G43TNXBBf//3yNa8Z1oGRIG0gDFYSq1c0 YZ6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681587080; x=1684179080; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Irete0T3ybMRlZOJLSsPU9NSiuY7uU8U7nsV28q8Ztk=; b=YbbPWKFNaiOzQeWSfR6Qktm4RpZAvpjuPM33g4A5QxFk5X5oiCBuDFcmlSiDirlThG GpWJrbM+IhqCfnHylJR+sdor7mathV1YEFsL4xlWKBpfZRpMcaOCZ0GwFS2XQRdb2uB/ tjx/KiOCbzy5KQkR3YX/fh/+ErittTO+jCu4naK24B2cJ/+N89Pm4/1CHK6RZI3tGfQ9 h7H4jNIm8OUi0/w8pKHLzEyXfNgjxCZvxlajX9lb/SIxgKYqZxdlflFRibL3Grub3CR3 /V7afYNs56oxbWuymj0yHW7C0Clb/yXi56oCFTO1iOUTSgd25YXWm/IFxoC2eZUqg3IF RQ4Q== X-Gm-Message-State: AAQBX9ciL0ES0DNAC9BhGlo7r+46Xn9vrbM+lF1IcYzWoI0X3rLb5TZp 28FqyqZIsy8LL6U777rgoMzTw/GsJQE= X-Google-Smtp-Source: AKy350ZipcLRUTs46ULtSj2EdXTddReyuny20zmNihwKCCHWpwXNixFCcyEa15Mq12APfVFwCNUGGg== X-Received: by 2002:a05:6214:21a4:b0:5a9:609d:e239 with SMTP id t4-20020a05621421a400b005a9609de239mr11080950qvc.48.1681587079825; Sat, 15 Apr 2023 12:31:19 -0700 (PDT) Received: from [127.0.0.1] (173-246-5-136.qc.cable.ebox.net. [173.246.5.136]) by smtp.gmail.com with ESMTPSA id f21-20020ac859d5000000b003e38f7e4562sm2086707qtf.69.2023.04.15.12.31.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Apr 2023 12:31:19 -0700 (PDT) From: Philippe Blain Date: Sat, 15 Apr 2023 15:30:59 -0400 Subject: [PATCH b4 1/2] mbox.py::make_am: simplify check for early return Precedence: bulk X-Mailing-List: tools@linux.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20230415-am-cherry-pick-suggestion-v1-1-8951a2274256@gmail.com> References: <20230415-am-cherry-pick-suggestion-v1-0-8951a2274256@gmail.com> In-Reply-To: <20230415-am-cherry-pick-suggestion-v1-0-8951a2274256@gmail.com> To: "Kernel.org Tools" Cc: Konstantin Ryabitsev , Philippe Blain X-Mailer: b4 0.13-dev-c01b1 In mbox.py::make_am, we check if the 'lser' LoreSeries returned by lmbx.get_series is empty, and return early with a different critical message depending on wether wantver was given or not. Simplify the logic a bit by using a nested if instead of two subsequent ones. This will make the following commit's diff simpler. Signed-off-by: Philippe Blain --- b4/mbox.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/b4/mbox.py b/b4/mbox.py index 7060564..05c40e9 100644 --- a/b4/mbox.py +++ b/b4/mbox.py @@ -57,11 +57,11 @@ def make_am(msgs: List[email.message.Message], cmdargs: argparse.Namespace, msgi reroll = False lser = lmbx.get_series(revision=wantver, sloppytrailers=cmdargs.sloppytrailers, reroll=reroll) - if lser is None and wantver is None: - logger.critical('No patches found.') - return if lser is None: - logger.critical('Unable to find revision %s', wantver) + if wantver is None: + logger.critical('No patches found.') + else: + logger.critical('Unable to find revision %s', wantver) return if len(lmbx.series) > 1 and not wantver: logger.info('Will use the latest revision: v%s', lser.revision) From patchwork Sat Apr 15 19:31:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain X-Patchwork-Id: 13212635 Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 183331868 for ; Sat, 15 Apr 2023 19:31:21 +0000 (UTC) Received: by mail-qt1-f178.google.com with SMTP id fv6so8986546qtb.9 for ; Sat, 15 Apr 2023 12:31:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681587081; x=1684179081; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=9uMVTnkWahtCHhlqnepki3K4OYKRJPBqyXo3m+29M1A=; b=BrUAuLhOHxvNR6sv1MdNH0kk8zVY5zQ36vR4kn2G0W7jJ1JoOKv913+EE7G+8Kyq+t CQSIL9DaYJEMpiV7mK38Vjl0HJZC54eh14PEFOUrgCc4H1XGmGQTdlcfNnBQzTZDiHCg AVdWLAK7PINCpI8vdrh4ZvG0rwDsnRQy3b863Zenu3JP4YlBYWm43QcmcYSOCHOOHpcj d0TwJ9lzDy5siPCPzFfYvxcaD7gbhr5Qn1fctuW79MQwucJ+vZMaVHj0/nKFqkDw127T FecVHVgAVPeU0foglwC+HqoJT2ldfWf4VdrIGiQlcJiFl3PL4pSly9oZpXpGSdAqHhio ayfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681587081; x=1684179081; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9uMVTnkWahtCHhlqnepki3K4OYKRJPBqyXo3m+29M1A=; b=MIaM+1Jy9P0fVS4ohiDo+4/NTYjQRY+NXpPLEurqOZS3YGeI9VuzARjZl4cTL+X403 fXOxRD3JDJaOfgl5cRMYwiN9rEwMZmACx6trk/b6PqV8I4BUmH6VuvoaWL7ebYE/YGAU AJcAImSWil3uQqZAkp7B3lsNBU0Dw1o4bgXTlQ9ux8DxcWryWySdr6sDp9r2o6SI8iWV UBP+DhaApfalw33TiS1wQAqHtILXHpQAAqxmmE67c22YQyW+5CPY5i8lZT5NF/X8S/ik pGGnnxuMciUFOrNBDw4szoyk5paW8RcWW70g1PJXCyz1oZEzeSuEcUTjD0ive7Yyz3HR aX/Q== X-Gm-Message-State: AAQBX9d3AQQ5nZq3IK0eXImNDTnns2XV8WtMGRDcVMXLK5UavqOGFFDq jOaDTV7ESukJTud4VqD13ZA= X-Google-Smtp-Source: AKy350bCXbUuY3/3QWEb7QWcOSBEp2spHZyI56jVf6Lut83QvmO91tLu9t9+dath09nq/vQxwrNbtg== X-Received: by 2002:ac8:7f8c:0:b0:3e8:fe33:4415 with SMTP id z12-20020ac87f8c000000b003e8fe334415mr16553025qtj.11.1681587080803; Sat, 15 Apr 2023 12:31:20 -0700 (PDT) Received: from [127.0.0.1] (173-246-5-136.qc.cable.ebox.net. [173.246.5.136]) by smtp.gmail.com with ESMTPSA id f21-20020ac859d5000000b003e38f7e4562sm2086707qtf.69.2023.04.15.12.31.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Apr 2023 12:31:20 -0700 (PDT) From: Philippe Blain Date: Sat, 15 Apr 2023 15:31:00 -0400 Subject: [PATCH b4 2/2] am, shazam: allow cherry-picking an out-of-series patch Precedence: bulk X-Mailing-List: tools@linux.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20230415-am-cherry-pick-suggestion-v1-2-8951a2274256@gmail.com> References: <20230415-am-cherry-pick-suggestion-v1-0-8951a2274256@gmail.com> In-Reply-To: <20230415-am-cherry-pick-suggestion-v1-0-8951a2274256@gmail.com> To: "Kernel.org Tools" Cc: Konstantin Ryabitsev , Philippe Blain X-Mailer: b4 0.13-dev-c01b1 Reviewers sometimes include a patch as a reply when reviewing a contributor's series, for example, to suggest tweaks or additional changes. The contributor might want to add that patch to their series for the next revision. Currently, using 'b4 shazam -P_ $msgid', where msgid is the message-id or full URL of the reviewer's message, does not work: $ b4 am -o- -P_ ZDnCMegeiw0kT5oj@nand.local Analyzing 2 messages in the thread No patches found. mbox.py::make_am returns early because the LoreSeries 'lser' returned by lmbx.get_series is empty ('None'). It is empty because when using '-P_', b4::retrieve_messages only retrieves the specific message-id given (and its replies), so the LoreSeries 'lmbx' created in make_am does not have any series. Also check if the user asked to cherry-pick a specific message-id before returning early in make_am. This allows us to reach the 'if cmdargs.cherrypick == '_'' condition, but then we iterate on lser.patches to find the patch to cherry-pick, and so get a runtime error: $ b4 am -o- -P_ ZDnCMegeiw0kT5oj@nand.local Analyzing 2 messages in the thread Traceback (most recent call last): File "/Users/Philippe/Code/b4/b4/command.py", line 381, in cmd() File "/Users/Philippe/Code/b4/b4/command.py", line 364, in cmd cmdargs.func(cmdargs) File "/Users/Philippe/Code/b4/b4/command.py", line 91, in cmd_am b4.mbox.main(cmdargs) File "/Users/Philippe/Code/b4/b4/mbox.py", line 719, in main make_am(msgs, cmdargs, msgid) File "/Users/Philippe/Code/b4/b4/mbox.py", line 82, in make_am for lmsg in lser.patches[1:]: AttributeError: 'NoneType' object has no attribute 'patches' Fix this by creating a fake LoreSeries and adding to it any followup messages in 'lmbx' with a diff in the body. Signed-off-by: Philippe Blain --- b4/mbox.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/b4/mbox.py b/b4/mbox.py index 05c40e9..70b866f 100644 --- a/b4/mbox.py +++ b/b4/mbox.py @@ -57,7 +57,7 @@ def make_am(msgs: List[email.message.Message], cmdargs: argparse.Namespace, msgi reroll = False lser = lmbx.get_series(revision=wantver, sloppytrailers=cmdargs.sloppytrailers, reroll=reroll) - if lser is None: + if lser is None and cmdargs.cherrypick != '_': if wantver is None: logger.critical('No patches found.') else: @@ -70,6 +70,13 @@ def make_am(msgs: List[email.message.Message], cmdargs: argparse.Namespace, msgi if cmdargs.cherrypick: cherrypick = list() if cmdargs.cherrypick == '_': + # We might want to pick a patch sent as a followup, so create a fake series + # and add followups with diffs + if lser is None: + lser = b4.LoreSeries(revision=1, expected=1) + for followup in lmbx.followups: + if followup.has_diff: + lser.add_patch(followup) # Only grab the exact msgid provided at = 0 for lmsg in lser.patches[1:]: