From 35feff7c737d885467fef4edc6d627e1e81a61b0 Mon Sep 17 00:00:00 2001 From: Peter Grayson Date: Fri, 7 Jan 2022 13:49:01 -0500 Subject: [PATCH] Pick --noapply does not reverse patches Replace pick '--unapplied' with '--noapply'. The new name is consistent with the same option in `stg push` and `stg float`. Using this option no longer reverses the order of the picked patches. Picking in the user-provided order seems to be the best approach. Repairs #174 Signed-off-by: Peter Grayson --- completion/stgit.zsh | 2 +- stgit/commands/pick.py | 10 ++++------ t/t3400-pick.sh | 49 +++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 46 insertions(+), 15 deletions(-) diff --git a/completion/stgit.zsh b/completion/stgit.zsh index bbcf1f5..a848c64 100644 --- a/completion/stgit.zsh +++ b/completion/stgit.zsh @@ -330,7 +330,7 @@ _stg-pick() { '(-r --revert)'{-r,--revert}'[revert given commit object]' '(-p --parent=)'{-p,--parent}'[use commit id as parent]:commit' '(-x --expose)'{-x,--expose}'[append imported commit id to patch log]' - '--unapplied[keep patch unapplied]' + '--noapply[keep patch unapplied]' '*'{-f,--file=}'[only fold given file]: :_files' '*:patches:__stg_patches_refbranch' + '(mode)' diff --git a/stgit/commands/pick.py b/stgit/commands/pick.py index 67017b3..446c99d 100644 --- a/stgit/commands/pick.py +++ b/stgit/commands/pick.py @@ -101,7 +101,7 @@ options = [ short='Only fold the given file (can be used multiple times)', ), opt( - '--unapplied', + '--noapply', action='store_true', short='Keep the patch unapplied', ), @@ -224,14 +224,14 @@ def __pick_commit(stack, ref_stack, iw, commit, patchname, options): ) ) - if not options.unapplied: + if not options.noapply: check_head_top_equal(stack) trans = StackTransaction(stack) trans.patches[patchname] = new_commit trans.unapplied.append(patchname) - if not options.unapplied: + if not options.noapply: try: trans.push_patch(patchname, iw, allow_interactive=True) except TransactionHalted: @@ -265,7 +265,7 @@ def func(parser, options, args): stack = repository.get_stack() iw = repository.default_iw - if not options.unapplied: + if not options.noapply: check_local_changes(repository) check_conflicts(iw) check_head_top_equal(stack) @@ -313,8 +313,6 @@ def func(parser, options, args): patchname = None retval = __pick_commit(stack, ref_stack, iw, commit, patchname, options) else: - if options.unapplied: - patches.reverse() for patchname in patches: commit = git_commit(patchname, repository, ref_stack.name) retval = __pick_commit(stack, ref_stack, iw, commit, patchname, options) diff --git a/t/t3400-pick.sh b/t/t3400-pick.sh index a3943a5..e4220b6 100755 --- a/t/t3400-pick.sh +++ b/t/t3400-pick.sh @@ -14,16 +14,33 @@ test_expect_success \ 'Initialize the StGit repository' \ ' stg init && - stg new A -m "a" && echo A > a && stg add a && stg refresh && - stg new B -m "b" && echo B > b && stg add b && stg refresh && + stg new A -m "a" && + echo A > a && + stg add a && + stg refresh && + stg new B -m "b" && + echo B > b && + stg add b && + stg refresh && stg branch --clone foo && - stg new C -m "c" && echo C > c && stg add c && stg refresh && - stg new D-foo -m "d" && echo D > d && stg add d && stg refresh && + stg new C -m "c" && + echo C > c && + stg add c && + stg refresh && + stg new D-foo -m "d" && + echo D > d && + stg add d && + stg refresh && stg new E -m "e" && - echo AA >> a && echo BB >> b && echo CC >> c && + echo AA >> a && + echo BB >> b && + echo CC >> c && stg refresh && stg new AAA -m "aaa" && - echo "A" > a && echo "AAA" >> a && echo "AA" >> a && stg refresh && + echo "A" > a && + echo "AAA" >> a && + echo "AA" >> a && + stg refresh && stg branch master ' @@ -50,9 +67,25 @@ test_expect_success \ ' test_expect_success \ - 'Pick --unapplied remote patch' \ + 'Pick --noapply remote patch' \ ' - stg pick --unapplied --ref-branch foo --name D D-foo && + stg pick --noapply --ref-branch foo --name D D-foo && + test "$(echo $(stg series --applied --noprefix))" = "A B C" && + test "$(echo $(stg series --unapplied --noprefix))" = "D" + ' + +test_expect_success \ + 'Pick --noapply several patches' \ + ' + stg delete C..D && + stg pick -B foo --noapply C E AAA && + test "$(echo $(stg series --applied --noprefix))" = "A B" && + test "$(echo $(stg series --unapplied --noprefix))" = "C E AAA" && + stg goto AAA && + test "$(echo $(cat a))" = "A AAA AA" && + stg goto C && + stg delete E AAA && + stg pick --noapply --name D foo:D-foo && test "$(echo $(stg series --applied --noprefix))" = "A B C" && test "$(echo $(stg series --unapplied --noprefix))" = "D" ' -- 2.11.4.GIT