aboutsummaryrefslogtreecommitdiff
path: root/b4/command.py
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2021-09-21 16:06:02 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2021-09-21 16:06:02 -0400
commitef97d5c407757d2b190a576f1f86330db6be036d (patch)
treef92604b59835c34085fa1d80953113db4f0c1afb /b4/command.py
parentd8937ede7064a74623a9d1ef260d5d50a146dd44 (diff)
downloadb4-ef97d5c407757d2b190a576f1f86330db6be036d.tar.gz
Add "b4 shazam" that is like b4 am + git am
By popular demand, provide a way to apply series straight to a git repository. By default, we're still going the safest possible route: - create a sparse worktree consisting just of the files being modified - run "git am" against the temporary worktree - if "git am" went well, fetch from the temporary worktree into our current tree and leave everything in FETCH_HEAD - unless we're running "b4 shazam -A" in which case we just apply to the current HEAD (exact equivalent of b4 am -o- | git am) Further changes to come based on feedback. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Diffstat (limited to 'b4/command.py')
-rw-r--r--b4/command.py62
1 files changed, 40 insertions, 22 deletions
diff --git a/b4/command.py b/b4/command.py
index 5bb3384..199d0c2 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,
@@ -35,6 +35,26 @@ def cmd_mbox_common_opts(sp):
sp.add_argument('-M', '--save-as-maildir', dest='maildir', action='store_true', default=False,
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 or sort any trailers')
+ 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')
+
def cmd_mbox(cmdargs):
import b4.mbox
@@ -51,6 +71,11 @@ def cmd_am(cmdargs):
b4.mbox.main(cmdargs)
+def cmd_shazam(cmdargs):
+ import b4.mbox
+ b4.mbox.main(cmdargs)
+
+
def cmd_attest(cmdargs):
import b4.attest
if len(cmdargs.patchfile):
@@ -100,41 +125,34 @@ 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,
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 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)
+ sp_sh.add_argument('--guess-lookback', dest='guessdays', type=int, default=21,
+ help = 'When guessing base, go back this many days from the patch date (default: 3 weeks)')
+ sp_sh.add_argument('-A', '--apply-here', dest='applyhere', action='store_true', default=False,
+ help = 'Apply to the current tree')
+ sp_sh.set_defaults(func=cmd_shazam)
+
# 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,
@@ -200,7 +218,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='+',