tools.linux.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Herring <robh@kernel.org>
To: "Kernel.org Tools" <tools@linux.kernel.org>
Cc: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Subject: [PATCH b4 2/2] prep: Allow configuration options when enrolling/creating branch
Date: Tue, 10 Jan 2023 15:46:08 -0600	[thread overview]
Message-ID: <20230110-prep-opts-v1-2-8e7d7b861849@kernel.org> (raw)
In-Reply-To: <20230110-prep-opts-v1-0-8e7d7b861849@kernel.org>

I tried 'b4 prep -c -e v6.2-rc1' thinking I could populate the To/Cc list
and enroll a branch in one step, but got this:

Will collect To: addresses using get_maintainer.pl
Will collect Cc: addresses using get_maintainer.pl
Traceback (most recent call last):
  File "/home/rob/.local/bin/b4", line 33, in <module>
    sys.exit(load_entry_point('b4', 'console_scripts', 'b4')())
  File "/home/rob/proj/b4/b4/command.py", line 359, in cmd
    cmdargs.func(cmdargs)
  File "/home/rob/proj/b4/b4/command.py", line 76, in cmd_prep
    b4.ez.cmd_prep(cmdargs)
  File "/home/rob/proj/b4/b4/ez.py", line 1875, in cmd_prep
    return auto_to_cc()
  File "/home/rob/proj/b4/b4/ez.py", line 1797, in auto_to_cc
    tos, ccs, tag_msg, patches = get_prep_branch_as_patches()
  File "/home/rob/proj/b4/b4/ez.py", line 1113, in get_prep_branch_as_patches
    prefixes = tracking['series'].get('prefixes', list())
KeyError: 'series'

Auto populating the To/Cc list currently has to be run by itself. That's
an unnecessary restriction, and it is useful to do that as part of setting
up a new or existing branch. The same applies to '--force-revision',
'--set-prefixes', and '--edit-cover'.

A side effect is these options will now be silently ignored if given with
other sub-commands (e.g. --show-revision).

Signed-off-by: Rob Herring <robh@kernel.org>
---
 b4/command.py | 13 +++++++------
 b4/ez.py      | 31 ++++++++++++++++---------------
 2 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/b4/command.py b/b4/command.py
index ccae05d24488..b4a02cef7fc7 100644
--- a/b4/command.py
+++ b/b4/command.py
@@ -257,23 +257,24 @@ def setup_parser() -> argparse.ArgumentParser:
 
     # b4 prep
     sp_prep = subparsers.add_parser('prep', help='Work on patch series to submit for mailing list review')
-    spp_g = sp_prep.add_mutually_exclusive_group()
-    spp_g.add_argument('-c', '--auto-to-cc', action='store_true', default=False,
+    sp_prep.add_argument('-c', '--auto-to-cc', action='store_true', default=False,
                        help='Automatically populate cover letter trailers with To and Cc addresses')
+    sp_prep.add_argument('--force-revision', metavar='N', type=int,
+                       help='Force revision to be this number instead')
+    sp_prep.add_argument('--set-prefixes', metavar='PREFIX', nargs='+',
+                       help='Extra prefixes to add to [PATCH] (e.g.: RFC mydrv)')
+
+    spp_g = sp_prep.add_mutually_exclusive_group()
     spp_g.add_argument('-p', '--format-patch', metavar='OUTPUT_DIR',
                        help='Output prep-tracked commits as patches')
     spp_g.add_argument('--edit-cover', action='store_true', default=False,
                        help='Edit the cover letter in your defined $EDITOR (or core.editor)')
     spp_g.add_argument('--show-revision', action='store_true', default=False,
                        help='Show current series revision number')
-    spp_g.add_argument('--force-revision', metavar='N', type=int,
-                       help='Force revision to be this number instead')
     spp_g.add_argument('--compare-to', metavar='vN',
                        help='Display a range-diff to previously sent revision N')
     spp_g.add_argument('--manual-reroll', dest='reroll', default=None, metavar='COVER_MSGID',
                        help='Mark current revision as sent and reroll (requires cover letter msgid)')
-    spp_g.add_argument('--set-prefixes', metavar='PREFIX', nargs='+',
-                       help='Extra prefixes to add to [PATCH] (e.g.: RFC mydrv)')
     spp_g.add_argument('--show-info', action='store_true', default=False,
                        help='Show current series info in a column-parseable format')
 
diff --git a/b4/ez.py b/b4/ez.py
index 1b7e390b7744..35c3e9c07ff6 100644
--- a/b4/ez.py
+++ b/b4/ez.py
@@ -480,7 +480,7 @@ def start_new_series(cmdargs: argparse.Namespace) -> None:
         if revision is None:
             revision = 1
         prefixes = list()
-        if cmdargs.set_prefixes and len(prefixes[0].strip()):
+        if cmdargs.set_prefixes:
             prefixes = list(cmdargs.set_prefixes)
         else:
             config = b4.get_main_config()
@@ -1881,12 +1881,6 @@ def cmd_prep(cmdargs: argparse.Namespace) -> None:
         logger.critical('          Stash or commit them first.')
         sys.exit(1)
 
-    if cmdargs.edit_cover:
-        return edit_cover()
-
-    if cmdargs.auto_to_cc:
-        return auto_to_cc()
-
     if cmdargs.reroll:
         msgid = cmdargs.reroll
         msgs = b4.get_pi_thread_by_msgid(msgid, onlymsgids={msgid}, nocache=True)
@@ -1913,23 +1907,30 @@ def cmd_prep(cmdargs: argparse.Namespace) -> None:
     if cmdargs.show_info:
         return show_info()
 
-    if cmdargs.force_revision:
-        return force_revision(cmdargs.force_revision)
-
     if cmdargs.format_patch:
         return format_patch(cmdargs.format_patch)
 
     if cmdargs.compare_to:
         return compare(cmdargs.compare_to)
 
+    if cmdargs.enroll_base or cmdargs.new_series_name:
+        if is_prep_branch():
+            logger.critical('CRITICAL: This appears to already be a b4-prep managed branch.')
+            sys.exit(1)
+
+        start_new_series(cmdargs)
+
+    if cmdargs.force_revision:
+        force_revision(cmdargs.force_revision)
+
     if cmdargs.set_prefixes:
-        return set_prefixes(cmdargs.set_prefixes)
+        set_prefixes(cmdargs.set_prefixes)
 
-    if is_prep_branch():
-        logger.critical('CRITICAL: This appears to already be a b4-prep managed branch.')
-        sys.exit(1)
+    if cmdargs.auto_to_cc:
+        auto_to_cc()
 
-    return start_new_series(cmdargs)
+    if cmdargs.edit_cover:
+        return edit_cover()
 
 
 def cmd_trailers(cmdargs: argparse.Namespace) -> None:

-- 
2.39.0


  parent reply	other threads:[~2023-01-10 21:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-10 21:46 [PATCH b4 0/2] A prep splat fix and rework of option handling Rob Herring
2023-01-10 21:46 ` [PATCH b4 1/2] prep: Fix splat with --auto-to-cc when a branch has no commits Rob Herring
2023-01-10 21:46 ` Rob Herring [this message]
2023-01-10 22:15 ` [PATCH b4 0/2] A prep splat fix and rework of option handling Rob Herring
2023-01-10 22:43   ` Konstantin Ryabitsev
2023-01-12 16:14 ` Konstantin Ryabitsev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230110-prep-opts-v1-2-8e7d7b861849@kernel.org \
    --to=robh@kernel.org \
    --cc=konstantin@linuxfoundation.org \
    --cc=tools@linux.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).