diff options
Diffstat (limited to 'b4/command.py')
-rw-r--r-- | b4/command.py | 173 |
1 files changed, 130 insertions, 43 deletions
diff --git a/b4/command.py b/b4/command.py index 5bb3384..5cd4425 100644 --- a/b4/command.py +++ b/b4/command.py @@ -17,7 +17,7 @@ def cmd_retrieval_common_opts(sp): sp.add_argument('msgid', nargs='?', help='Message ID to process, or pipe a raw message') sp.add_argument('-p', '--use-project', dest='useproject', default=None, - help='Use a specific project instead of guessing (linux-mm, linux-hardening, etc)') + help='Use a specific project instead of default (linux-mm, linux-hardening, etc)') sp.add_argument('-m', '--use-local-mbox', dest='localmbox', default=None, help='Instead of grabbing a thread from lore, process this mbox file (or - for stdin)') sp.add_argument('-C', '--no-cache', dest='nocache', action='store_true', default=False, @@ -36,6 +36,31 @@ def cmd_mbox_common_opts(sp): help='Save as maildir (avoids mbox format ambiguities)') +def cmd_am_common_opts(sp): + sp.add_argument('-v', '--use-version', dest='wantver', type=int, default=None, + help='Get a specific version of the patch/series') + sp.add_argument('-t', '--apply-cover-trailers', dest='covertrailers', action='store_true', default=False, + help='Apply trailers sent to the cover letter to all patches') + sp.add_argument('-S', '--sloppy-trailers', dest='sloppytrailers', action='store_true', default=False, + help='Apply trailers without email address match checking') + sp.add_argument('-T', '--no-add-trailers', dest='noaddtrailers', action='store_true', default=False, + help='Do not add any trailers from follow-up messages') + sp.add_argument('-s', '--add-my-sob', dest='addmysob', action='store_true', default=False, + help='Add your own signed-off-by to every patch') + sp.add_argument('-l', '--add-link', dest='addlink', action='store_true', default=False, + help='Add a Link: with message-id lookup URL to every patch') + sp.add_argument('-P', '--cherry-pick', dest='cherrypick', default=None, + help='Cherry-pick a subset of patches (e.g. "-P 1-2,4,6-", ' + '"-P _" to use just the msgid specified, or ' + '"-P *globbing*" to match on commit subject)') + sp.add_argument('--cc-trailers', dest='copyccs', action='store_true', default=False, + help='Copy all Cc\'d addresses into Cc: trailers') + sp.add_argument('--no-parent', dest='noparent', action='store_true', default=False, + help='Break thread at the msgid specified and ignore any parent messages') + sp.add_argument('--allow-unicode-control-chars', dest='allowbadchars', action='store_true', default=False, + help='Allow unicode control characters (very rarely legitimate)') + + def cmd_mbox(cmdargs): import b4.mbox b4.mbox.main(cmdargs) @@ -46,18 +71,29 @@ def cmd_kr(cmdargs): b4.kr.main(cmdargs) +def cmd_prep(cmdargs): + import b4.ez + b4.ez.cmd_prep(cmdargs) + + +def cmd_trailers(cmdargs): + import b4.ez + b4.ez.cmd_trailers(cmdargs) + + +def cmd_send(cmdargs): + import b4.ez + b4.ez.cmd_send(cmdargs) + + def cmd_am(cmdargs): import b4.mbox b4.mbox.main(cmdargs) -def cmd_attest(cmdargs): - import b4.attest - if len(cmdargs.patchfile): - b4.attest.attest_patches(cmdargs) - else: - logger.critical('ERROR: missing patches to attest') - sys.exit(1) +def cmd_shazam(cmdargs): + import b4.mbox + b4.mbox.main(cmdargs) def cmd_pr(cmdargs): @@ -87,6 +123,8 @@ def cmd(): help='Add more debugging info to the output') parser.add_argument('-q', '--quiet', action='store_true', default=False, help='Output critical information only') + parser.add_argument('-n', '--no-interactive', action='store_true', default=False, + help='Do not ask any interactive questions') subparsers = parser.add_subparsers(help='sub-command help', dest='subcmd') @@ -100,53 +138,37 @@ def cmd(): # b4 am sp_am = subparsers.add_parser('am', help='Create an mbox file that is ready to git-am') cmd_mbox_common_opts(sp_am) - sp_am.add_argument('-v', '--use-version', dest='wantver', type=int, default=None, - help='Get a specific version of the patch/series') - sp_am.add_argument('-t', '--apply-cover-trailers', dest='covertrailers', action='store_true', default=False, - help='Apply trailers sent to the cover letter to all patches') - sp_am.add_argument('-S', '--sloppy-trailers', dest='sloppytrailers', action='store_true', default=False, - help='Apply trailers without email address match checking') - sp_am.add_argument('-T', '--no-add-trailers', dest='noaddtrailers', action='store_true', default=False, - help='Do not add or sort any trailers') - sp_am.add_argument('-s', '--add-my-sob', dest='addmysob', action='store_true', default=False, - help='Add your own signed-off-by to every patch') - sp_am.add_argument('-l', '--add-link', dest='addlink', action='store_true', default=False, - help='Add a lore.kernel.org/r/ link to every patch') + cmd_am_common_opts(sp_am) sp_am.add_argument('-Q', '--quilt-ready', dest='quiltready', action='store_true', default=False, help='Save patches in a quilt-ready folder') - sp_am.add_argument('-P', '--cherry-pick', dest='cherrypick', default=None, - help='Cherry-pick a subset of patches (e.g. "-P 1-2,4,6-", ' - '"-P _" to use just the msgid specified, or ' - '"-P *globbing*" to match on commit subject)') sp_am.add_argument('-g', '--guess-base', dest='guessbase', action='store_true', default=False, help='Try to guess the base of the series (if not specified)') - sp_am.add_argument('-b', '--guess-branch', dest='guessbranch', default=None, + sp_am.add_argument('-b', '--guess-branch', dest='guessbranch', nargs='+', action='extend', type=str, default=None, help='When guessing base, restrict to this branch (use with -g)') - sp_am.add_argument('--guess-lookback', dest='guessdays', type=int, default=14, - help='When guessing base, go back this many days from the date of the patch') + sp_am.add_argument('--guess-lookback', dest='guessdays', type=int, default=21, + help='When guessing base, go back this many days from the patch date (default: 2 weeks)') sp_am.add_argument('-3', '--prep-3way', dest='threeway', action='store_true', default=False, help='Prepare for a 3-way merge ' '(tries to ensure that all index blobs exist by making a fake commit range)') - sp_am.add_argument('--cc-trailers', dest='copyccs', action='store_true', default=False, - help='Copy all Cc\'d addresses into Cc: trailers') sp_am.add_argument('--no-cover', dest='nocover', action='store_true', default=False, help='Do not save the cover letter (on by default when using -o -)') sp_am.add_argument('--no-partial-reroll', dest='nopartialreroll', action='store_true', default=False, help='Do not reroll partial series when detected') sp_am.set_defaults(func=cmd_am) - # b4 attest - sp_att = subparsers.add_parser('attest', help='Create cryptographic attestation for a set of patches') - sp_att.add_argument('-f', '--from', dest='sender', default=None, - help='OBSOLETE: this option does nothing and will be removed') - sp_att.add_argument('-n', '--no-submit', dest='nosubmit', action='store_true', default=False, - help='OBSOLETE: this option does nothing and will be removed') - sp_att.add_argument('-o', '--output', default=None, - help='OBSOLETE: this option does nothing and will be removed') - sp_att.add_argument('-m', '--mutt-filter', default=None, - help='OBSOLETE: this option does nothing and will be removed') - sp_att.add_argument('patchfile', nargs='*', help='Patches to attest') - sp_att.set_defaults(func=cmd_attest) + # b4 shazam + sp_sh = subparsers.add_parser('shazam', help='Like b4 am, but applies the series to your tree') + cmd_retrieval_common_opts(sp_sh) + cmd_am_common_opts(sp_sh) + sh_g = sp_sh.add_mutually_exclusive_group() + sh_g.add_argument('-H', '--make-fetch-head', dest='makefetchhead', action='store_true', default=False, + help='Attempt to treat series as a pull request and fetch it into FETCH_HEAD') + sh_g.add_argument('-M', '--merge', dest='merge', action='store_true', default=False, + help='Attempt to merge series as if it were a pull request (execs git-merge)') + sp_sh.add_argument('--guess-lookback', dest='guessdays', type=int, default=21, + help=('(use with -H or -M) When guessing base, go back this many days from the patch date ' + '(default: 3 weeks)')) + sp_sh.set_defaults(func=cmd_shazam) # b4 pr sp_pr = subparsers.add_parser('pr', help='Fetch a pull request found in a message ID') @@ -181,7 +203,7 @@ def cmd(): help='Write thanks files into this dir (default=.)') sp_ty.add_argument('-l', '--list', action='store_true', default=False, help='List pull requests and patch series you have retrieved') - sp_ty.add_argument('-s', '--send', default=None, + sp_ty.add_argument('-t', '--thank-for', dest='thankfor', default=None, help='Generate thankyous for specific entries from -l (e.g.: 1,3-5,7-; or "all")') sp_ty.add_argument('-d', '--discard', default=None, help='Discard specific messages from -l (e.g.: 1,3-5,7-; or "all")') @@ -191,6 +213,12 @@ def cmd(): help='The branch to check against, instead of current') sp_ty.add_argument('--since', default='1.week', help='The --since option to use when auto-matching patches (default=1.week)') + sp_ty.add_argument('-S', '--send-email', action='store_true', dest='sendemail', default=False, + help='Send email instead of writing out .thanks files') + sp_ty.add_argument('--dry-run', action='store_true', dest='dryrun', default=False, + help='Print out emails instead of sending them') + sp_ty.add_argument('--pw-set-state', default=None, + help='Set this patchwork state instead of default (use with -a, -t or -d)') sp_ty.set_defaults(func=cmd_ty) # b4 diff @@ -200,7 +228,7 @@ def cmd(): sp_diff.add_argument('-g', '--gitdir', default=None, help='Operate on this git tree instead of current dir') sp_diff.add_argument('-p', '--use-project', dest='useproject', default=None, - help='Use a specific project instead of guessing (linux-mm, linux-hardening, etc)') + help='Use a specific project instead of default (linux-mm, linux-hardening, etc)') sp_diff.add_argument('-C', '--no-cache', dest='nocache', action='store_true', default=False, help='Do not use local cache') sp_diff.add_argument('-v', '--compare-versions', dest='wantvers', type=int, default=None, nargs='+', @@ -222,6 +250,65 @@ def cmd(): help='Show all developer keys found in a thread') sp_kr.set_defaults(func=cmd_kr) + # b4 prep + sp_prep = subparsers.add_parser('prep', help='Work on patch series to submit for mailing list review') + sp_prep.add_argument('--edit-cover', action='store_true', default=False, + help='Edit the cover letter in your defined $EDITOR (or core.editor)') + sp_prep.add_argument('--show-revision', action='store_true', default=False, + help='Show current series revision number') + sp_prep.add_argument('--force-revision', default=False, metavar='N', type=int, + help='Force revision to be this number instead') + sp_prep.add_argument('--format-patch', metavar='OUTPUT_DIR', + help='Output prep-tracked commits as patches') + ag_prepn = sp_prep.add_argument_group('Create new branch', 'Create a new branch for working on patch series') + ag_prepn.add_argument('-n', '--new', dest='new_series_name', + help='Create a new branch for working on a patch series') + ag_prepn.add_argument('-f', '--fork-point', dest='fork_point', + help='When creating a new branch, use this fork point instead of HEAD') + ag_prepn.add_argument('-F', '--from-thread', metavar='MSGID', dest='msgid', + help='When creating a new branch, use this thread') + ag_prepe = sp_prep.add_argument_group('Enroll existing branch', 'Enroll existing branch for prep work') + ag_prepe.add_argument('-e', '--enroll', dest='enroll_base', + help='Enroll current branch, using the passed tag, branch, or commit as fork base') + sp_prep.set_defaults(func=cmd_prep) + + # b4 trailers + sp_trl = subparsers.add_parser('trailers', help='Operate on trailers received for mailing list reviews') + sp_trl.add_argument('-u', '--update', action='store_true', default=False, + help='Update branch commits with latest received trailers') + sp_trl.add_argument('-S', '--sloppy-trailers', dest='sloppytrailers', action='store_true', default=False, + help='Apply trailers without email address match checking') + sp_trl.add_argument('-F', '--trailers-from', dest='msgid', + help='Look for trailers in the thread with this msgid instead of using the series change-id') + sp_trl.add_argument('--since', default='1.month', + help='The --since option to use with -F when auto-matching patches (default=1.month)') + sp_trl.set_defaults(func=cmd_trailers) + + # b4 send + sp_send = subparsers.add_parser('send', help='Submit your work for review on the mailing lists') + sp_send.add_argument('-d', '--dry-run', dest='dryrun', action='store_true', default=False, + help='Do not send, just dump out raw smtp messages to the stdout') + sp_send.add_argument('-o', '--output-dir', + help='Do not send, write raw messages to this directory (forces --dry-run)') + sp_send.add_argument('--prefixes', nargs='+', + help='Prefixes to add to PATCH (e.g. RFC, WIP)') + sp_send.add_argument('--no-auto-to-cc', action='store_true', default=False, + help='Do not automatically collect To: and Cc: addresses') + sp_send.add_argument('--to', nargs='+', help='Addresses to add to the To: list') + sp_send.add_argument('--cc', nargs='+', help='Addresses to add to the Cc: list') + sp_send.add_argument('--not-me-too', action='store_true', default=False, + help='Remove yourself from the To: or Cc: list') + sp_send.add_argument('--resend', default=None, + help='Resend a previously sent version of the series') + sp_send.add_argument('--no-sign', action='store_true', default=False, + help='Do not cryptographically sign your patches with patatt') + ag_sendh = sp_send.add_argument_group('Web submission', 'Authenticate with the web submission endpoint') + ag_sendh.add_argument('--web-auth-new', dest='auth_new', action='store_true', default=False, + help='Initiate a new web authentication request') + ag_sendh.add_argument('--web-auth-verify', dest='auth_verify', metavar='VERIFY_TOKEN', + help='Submit the token received via verification email') + sp_send.set_defaults(func=cmd_send) + cmdargs = parser.parse_args() logger.setLevel(logging.DEBUG) |