@@ -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')
@@ -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:
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(-)