tools.linux.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH b4 0/2] am, shazam: allow cherry-picking an out-of-series patch
@ 2023-04-15 19:30 Philippe Blain
  2023-04-15 19:30 ` [PATCH b4 1/2] mbox.py::make_am: simplify check for early return Philippe Blain
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Philippe Blain @ 2023-04-15 19:30 UTC (permalink / raw)
  To: Kernel.org Tools; +Cc: Konstantin Ryabitsev, Philippe Blain

This series makes am and shazam able to cherry-pick a patch sent by a reviewer
as a suggestion (second patch). The first patch is a preparatory
simplification.

If you want to test it, you can do so in a clone of git.git:

    git clone https://github.com/gitgitgadget/git -b pr-1515/phil-blain/doc-auto-merge-v1
    git checkout 66c7e51415
    b4 am -o- -P_ https://lore.kernel.org/git/ZDnCMegeiw0kT5oj@nand.local/

Cheers,

Philippe.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
---
Philippe Blain (2):
      mbox.py::make_am: simplify check for early return
      am, shazam: allow cherry-picking an out-of-series patch

 b4/mbox.py | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
---
base-commit: 00303592f25693cb4eddf58fb51063afcff8dceb
change-id: 20230415-am-cherry-pick-suggestion-86a994778a6c


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH b4 1/2] mbox.py::make_am: simplify check for early return
  2023-04-15 19:30 [PATCH b4 0/2] am, shazam: allow cherry-picking an out-of-series patch Philippe Blain
@ 2023-04-15 19:30 ` Philippe Blain
  2023-04-15 19:31 ` [PATCH b4 2/2] am, shazam: allow cherry-picking an out-of-series patch Philippe Blain
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Philippe Blain @ 2023-04-15 19:30 UTC (permalink / raw)
  To: Kernel.org Tools; +Cc: Konstantin Ryabitsev, Philippe Blain

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 <levraiphilippeblain@gmail.com>
---
 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)

-- 
2.39.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH b4 2/2] am, shazam: allow cherry-picking an out-of-series patch
  2023-04-15 19:30 [PATCH b4 0/2] am, shazam: allow cherry-picking an out-of-series patch Philippe Blain
  2023-04-15 19:30 ` [PATCH b4 1/2] mbox.py::make_am: simplify check for early return Philippe Blain
@ 2023-04-15 19:31 ` Philippe Blain
  2023-05-06 20:23 ` [PATCH b4 0/2] " Philippe Blain
  2023-05-26 18:28 ` Konstantin Ryabitsev
  3 siblings, 0 replies; 5+ messages in thread
From: Philippe Blain @ 2023-04-15 19:31 UTC (permalink / raw)
  To: Kernel.org Tools; +Cc: Konstantin Ryabitsev, Philippe Blain

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 <module>
        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 <levraiphilippeblain@gmail.com>
---
 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:]:

-- 
2.39.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH b4 0/2] am, shazam: allow cherry-picking an out-of-series patch
  2023-04-15 19:30 [PATCH b4 0/2] am, shazam: allow cherry-picking an out-of-series patch Philippe Blain
  2023-04-15 19:30 ` [PATCH b4 1/2] mbox.py::make_am: simplify check for early return Philippe Blain
  2023-04-15 19:31 ` [PATCH b4 2/2] am, shazam: allow cherry-picking an out-of-series patch Philippe Blain
@ 2023-05-06 20:23 ` Philippe Blain
  2023-05-26 18:28 ` Konstantin Ryabitsev
  3 siblings, 0 replies; 5+ messages in thread
From: Philippe Blain @ 2023-05-06 20:23 UTC (permalink / raw)
  To: Kernel.org Tools; +Cc: Konstantin Ryabitsev

Hi Konstantin, 

Le 2023-04-15 à 15:30, Philippe Blain a écrit :
> This series makes am and shazam able to cherry-pick a patch sent by a reviewer
> as a suggestion (second patch). The first patch is a preparatory
> simplification.
> 
> If you want to test it, you can do so in a clone of git.git:
> 
>     git clone https://github.com/gitgitgadget/git -b pr-1515/phil-blain/doc-auto-merge-v1
>     git checkout 66c7e51415
>     b4 am -o- -P_ https://lore.kernel.org/git/ZDnCMegeiw0kT5oj@nand.local/
> 
> Cheers,
> 
> Philippe.

Friendly ping ?

Cheers,
Philippe.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH b4 0/2] am, shazam: allow cherry-picking an out-of-series patch
  2023-04-15 19:30 [PATCH b4 0/2] am, shazam: allow cherry-picking an out-of-series patch Philippe Blain
                   ` (2 preceding siblings ...)
  2023-05-06 20:23 ` [PATCH b4 0/2] " Philippe Blain
@ 2023-05-26 18:28 ` Konstantin Ryabitsev
  3 siblings, 0 replies; 5+ messages in thread
From: Konstantin Ryabitsev @ 2023-05-26 18:28 UTC (permalink / raw)
  To: Kernel.org Tools, Philippe Blain


On Sat, 15 Apr 2023 15:30:58 -0400, Philippe Blain wrote:
> This series makes am and shazam able to cherry-pick a patch sent by a reviewer
> as a suggestion (second patch). The first patch is a preparatory
> simplification.
> 
> If you want to test it, you can do so in a clone of git.git:
> 
>     git clone https://github.com/gitgitgadget/git -b pr-1515/phil-blain/doc-auto-merge-v1
>     git checkout 66c7e51415
>     b4 am -o- -P_ https://lore.kernel.org/git/ZDnCMegeiw0kT5oj@nand.local/
> 
> [...]

Applied, thanks!

[1/2] mbox.py::make_am: simplify check for early return
      commit: 6c9ad4ec28f9a14cd8d20c933eef7bce0285a60a
[2/2] am, shazam: allow cherry-picking an out-of-series patch
      commit: 5872a3cfbb27a8511ee8a07f2b1a5bc79163dcd6

Best regards,
-- 
Konstantin Ryabitsev <konstantin@linuxfoundation.org>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-05-26 18:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-15 19:30 [PATCH b4 0/2] am, shazam: allow cherry-picking an out-of-series patch Philippe Blain
2023-04-15 19:30 ` [PATCH b4 1/2] mbox.py::make_am: simplify check for early return Philippe Blain
2023-04-15 19:31 ` [PATCH b4 2/2] am, shazam: allow cherry-picking an out-of-series patch Philippe Blain
2023-05-06 20:23 ` [PATCH b4 0/2] " Philippe Blain
2023-05-26 18:28 ` Konstantin Ryabitsev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).