[PATCH 17/20] patman: Move arguments for sent into the correct parser
Simon Glass
sjg at chromium.org
Thu May 8 09:28:41 CEST 2025
Most of the arguments for the main parser are actually arguments for the
'send' parser. Move them there, in a separate function.
Fix a pylint warning for -D and the imports while here.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
tools/patman/cmdline.py | 124 +++++++++++++++++++++++-----------------
1 file changed, 72 insertions(+), 52 deletions(-)
diff --git a/tools/patman/cmdline.py b/tools/patman/cmdline.py
index cb4e68c7cd8..912d488ff74 100644
--- a/tools/patman/cmdline.py
+++ b/tools/patman/cmdline.py
@@ -13,78 +13,102 @@ import os
import pathlib
import sys
-from patman import project
from u_boot_pylib import gitutil
+from patman import project
from patman import settings
PATMAN_DIR = pathlib.Path(__file__).parent
HAS_TESTS = os.path.exists(PATMAN_DIR / "func_test.py")
-def add_send_subparser(subparsers):
- """Add the 'send' subparser
-
- Args:
- subparsers (argparse action): Subparser parent
+def add_send_args(par):
+ """Add arguments for the 'send' command
- Return:
- ArgumentParser: send subparser
+ Arguments:
+ par (ArgumentParser): Parser to add to
"""
- send = subparsers.add_parser(
- 'send', help='Format, check and email patches (default command)')
- send.add_argument(
+ par.add_argument(
+ '-c', '--count', dest='count', type=int, default=-1,
+ help='Automatically create patches from top n commits')
+ par.add_argument(
+ '-e', '--end', type=int, default=0,
+ help='Commits to skip at end of patch list')
+ par.add_argument(
'-i', '--ignore-errors', action='store_true',
dest='ignore_errors', default=False,
help='Send patches email even if patch errors are found')
- send.add_argument(
+ par.add_argument(
'-l', '--limit-cc', dest='limit', type=int, default=None,
help='Limit the cc list to LIMIT entries [default: %(default)s]')
- send.add_argument(
+ par.add_argument(
'-m', '--no-maintainers', action='store_false',
dest='add_maintainers', default=True,
help="Don't cc the file maintainers automatically")
- send.add_argument(
+ par.add_argument(
'--get-maintainer-script', dest='get_maintainer_script', type=str,
action='store',
default=os.path.join(gitutil.get_top_level(), 'scripts',
'get_maintainer.pl') + ' --norolestats',
help='File name of the get_maintainer.pl (or compatible) script.')
- send.add_argument(
- '-n', '--dry-run', action='store_true', dest='dry_run',
- default=False, help="Do a dry run (create but don't email patches)")
- send.add_argument('-r', '--in-reply-to', type=str, action='store',
- help="Message ID that this series is in reply to")
- send.add_argument('-t', '--ignore-bad-tags', action='store_true',
- default=False,
- help='Ignore bad tags / aliases (default=warn)')
- send.add_argument('-T', '--thread', action='store_true', dest='thread',
- default=False, help='Create patches as a single thread')
- send.add_argument(
- '--cc-cmd', dest='cc_cmd', type=str, action='store',
- default=None, help='Output cc list for patch file (used by git)')
- send.add_argument('--no-binary', action='store_true', dest='ignore_binary',
- default=False,
- help="Do not output contents of changes in binary files")
- send.add_argument('--no-check', action='store_false', dest='check_patch',
- default=True,
- help="Don't check for patch compliance")
- send.add_argument(
+ par.add_argument(
+ '-r', '--in-reply-to', type=str, action='store',
+ help="Message ID that this series is in reply to")
+ par.add_argument(
+ '-s', '--start', dest='start', type=int, default=0,
+ help='Commit to start creating patches from (0 = HEAD)')
+ par.add_argument(
+ '-t', '--ignore-bad-tags', action='store_true', default=False,
+ help='Ignore bad tags / aliases (default=warn)')
+ par.add_argument(
+ '--no-binary', action='store_true', dest='ignore_binary',
+ default=False,
+ help="Do not output contents of changes in binary files")
+ par.add_argument(
+ '--no-check', action='store_false', dest='check_patch', default=True,
+ help="Don't check for patch compliance")
+ par.add_argument(
'--tree', dest='check_patch_use_tree', default=False,
action='store_true',
help=("Set `tree` to True. If `tree` is False then we'll pass "
"'--no-tree' to checkpatch (default: tree=%(default)s)"))
- send.add_argument('--no-tree', dest='check_patch_use_tree',
- action='store_false', help="Set `tree` to False")
- send.add_argument(
+ par.add_argument(
+ '--no-tree', dest='check_patch_use_tree', action='store_false',
+ help="Set `tree` to False")
+ par.add_argument(
'--no-tags', action='store_false', dest='process_tags', default=True,
help="Don't process subject tags as aliases")
- send.add_argument('--no-signoff', action='store_false', dest='add_signoff',
- default=True, help="Don't add Signed-off-by to patches")
- send.add_argument('--smtp-server', type=str,
- help="Specify the SMTP server to 'git send-email'")
- send.add_argument('--keep-change-id', action='store_true',
- help='Preserve Change-Id tags in patches to send.')
+ par.add_argument(
+ '--no-signoff', action='store_false', dest='add_signoff',
+ default=True, help="Don't add Signed-off-by to patches")
+ par.add_argument(
+ '--smtp-server', type=str,
+ help="Specify the SMTP server to 'git send-email'")
+ par.add_argument(
+ '--keep-change-id', action='store_true',
+ help='Preserve Change-Id tags in patches to send.')
+
+def add_send_subparser(subparsers):
+ """Add the 'send' subparser
+
+ Args:
+ subparsers (argparse action): Subparser parent
+
+ Return:
+ ArgumentParser: send subparser
+ """
+ send = subparsers.add_parser(
+ 'send', help='Format, check and email patches (default command)')
+ send.add_argument(
+ '-b', '--branch', type=str,
+ help="Branch to process (by default, the current branch)")
+ send.add_argument(
+ '-n', '--dry-run', action='store_true', dest='dry_run',
+ default=False, help="Do a dry run (create but don't email patches)")
+ send.add_argument(
+ '--cc-cmd', dest='cc_cmd', type=str, action='store',
+ default=None, help='Output cc list for patch file (used by git)')
+ add_send_args(send)
send.add_argument('patchfiles', nargs='*')
return send
@@ -123,13 +147,8 @@ def setup_parser():
run first.'''
parser = argparse.ArgumentParser(epilog=epilog)
- parser.add_argument('-b', '--branch', type=str,
- help="Branch to process (by default, the current branch)")
- parser.add_argument('-c', '--count', dest='count', type=int,
- default=-1, help='Automatically create patches from top n commits')
- parser.add_argument('-e', '--end', type=int, default=0,
- help='Commits to skip at end of patch list')
- parser.add_argument('-D', '--debug', action='store_true',
+ parser.add_argument(
+ '-D', '--debug', action='store_true',
help='Enabling debugging (provides a full traceback on error)')
parser.add_argument(
'-N', '--no-capture', action='store_true',
@@ -140,8 +159,9 @@ def setup_parser():
parser.add_argument('-P', '--patchwork-url',
default='https://patchwork.ozlabs.org',
help='URL of patchwork server [default: %(default)s]')
- parser.add_argument('-s', '--start', dest='start', type=int,
- default=0, help='Commit to start creating patches from (0 = HEAD)')
+ parser.add_argument(
+ '-T', '--thread', action='store_true', dest='thread',
+ default=False, help='Create patches as a single thread')
parser.add_argument(
'-v', '--verbose', action='store_true', dest='verbose', default=False,
help='Verbose output of errors and warnings')
--
2.43.0
More information about the U-Boot
mailing list