{"thread":{"id":"15616","subject":"[StGit PATCH 1/2] Add a new flag, --spill, to stg delete","startedAt":"2008-09-21T19:07:24Z","lastAt":"2008-09-21T19:07:36Z","messageCount":3,"participants":["Karl Hasselström"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"91256","messageId":"20080921190708.4503.20574.stgit@yoghurt","threadId":"15616","inReplyTo":null,"subject":"[StGit PATCH 0/2] stg delete --spill","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2008-09-21T19:07:24Z","receivedAt":"2008-09-21T19:07:24Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"---\n\nKarl Hasselström (2):\n      Test the new stg delete --spill flag\n      Add a new flag, --spill, to stg delete\n\n\n stgit/commands/delete.py |   13 +++++++++++++\n t/t1602-delete-spill.sh  |   47 ++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 60 insertions(+), 0 deletions(-)\n create mode 100755 t/t1602-delete-spill.sh\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"},{"id":"91253","messageId":"20080921190730.4503.52714.stgit@yoghurt","threadId":"15616","inReplyTo":"20080921190708.4503.20574.stgit@yoghurt","subject":"[StGit PATCH 1/2] Add a new flag, --spill, to stg delete","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2008-09-21T19:07:30Z","receivedAt":"2008-09-21T19:07:30Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"It deletes the patches as usual, but doesn't touch index+worktree.\nUseful for splitting up a patch, or undoing an \"stg refresh\".\n\nSigned-off-by: Karl Hasselström <kha@treskal.com>\n\n---\n\n stgit/commands/delete.py |   13 +++++++++++++\n 1 files changed, 13 insertions(+), 0 deletions(-)\n\n\ndiff --git a/stgit/commands/delete.py b/stgit/commands/delete.py\nindex 1b59cdd..015fb49 100644\n--- a/stgit/commands/delete.py\n+++ b/stgit/commands/delete.py\n@@ -30,6 +30,13 @@ Delete the patches passed as arguments.\"\"\"\n args = [argparse.patch_range(argparse.applied_patches,\n                              argparse.unapplied_patches)]\n options = [\n+    opt('--spill', action = 'store_true',\n+        short = 'Spill patch contents to worktree and index', long = \"\"\"\n+        Delete the patches, but do not touch the index and worktree.\n+        This only works with applied patches at the top of the stack.\n+        The effect is to \"spill\" the patch contents into the index and\n+        worktree. This can be useful e.g. if you want to split a patch\n+        into several smaller pieces.\"\"\"),\n     opt('-b', '--branch', args = [argparse.stg_branches],\n         short = 'Use BRANCH instead of the default branch')]\n \n@@ -46,6 +53,12 @@ def func(parser, options, args):\n         patches = set(common.parse_patches(args, list(stack.patchorder.all)))\n     else:\n         parser.error('No patches specified')\n+\n+    if options.spill:\n+        if set(stack.patchorder.applied[-len(patches):]) != patches:\n+            parser.error('Can only spill topmost applied patches')\n+        iw = None # don't touch index+worktree\n+\n     def allow_conflicts(trans):\n         # Allow conflicts if the topmost patch stays the same.\n         if stack.patchorder.applied:\n"},{"id":"91254","messageId":"20080921190736.4503.80527.stgit@yoghurt","threadId":"15616","inReplyTo":"20080921190708.4503.20574.stgit@yoghurt","subject":"[StGit PATCH 2/2] Test the new stg delete --spill flag","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2008-09-21T19:07:36Z","receivedAt":"2008-09-21T19:07:36Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"Signed-off-by: Karl Hasselström <kha@treskal.com>\n\n---\n\n t/t1602-delete-spill.sh |   47 +++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 47 insertions(+), 0 deletions(-)\n create mode 100755 t/t1602-delete-spill.sh\n\n\ndiff --git a/t/t1602-delete-spill.sh b/t/t1602-delete-spill.sh\nnew file mode 100755\nindex 0000000..1ddec53\n--- /dev/null\n+++ b/t/t1602-delete-spill.sh\n@@ -0,0 +1,47 @@\n+#!/bin/sh\n+test_description='Test \"stg delete --spill\"'\n+. ./test-lib.sh\n+\n+test_expect_success 'Initialize the StGIT repository' '\n+    stg init\n+'\n+\n+test_expect_success 'Create five applied and three unapplied patches' '\n+    for i in 0 1 2 3 4 5 6 7; do\n+        echo $i >> foo &&\n+        git add foo &&\n+        git commit -m p$i\n+    done\n+    stg uncommit -n 8 &&\n+    stg pop -n 3\n+'\n+\n+test_expect_success 'Try to delete --spill an unapplied patch' '\n+    command_error stg delete --spill p7 &&\n+    test \"$(echo $(stg series))\" = \"+ p0 + p1 + p2 + p3 > p4 - p5 - p6 - p7\" &&\n+    test \"$(echo $(cat foo))\" = \"0 1 2 3 4\" &&\n+    test \"$(echo $(git diff-files))\" = \"\"\n+'\n+\n+test_expect_success 'Try to delete --spill a non-top patch' '\n+    command_error stg delete --spill p2 &&\n+    test \"$(echo $(stg series))\" = \"+ p0 + p1 + p2 + p3 > p4 - p5 - p6 - p7\" &&\n+    test \"$(echo $(cat foo))\" = \"0 1 2 3 4\" &&\n+    test \"$(echo $(git diff-files))\" = \"\"\n+'\n+\n+test_expect_success 'Delete --spill one patch' '\n+    stg delete --spill p4 &&\n+    test \"$(echo $(stg series))\" = \"+ p0 + p1 + p2 > p3 - p5 - p6 - p7\" &&\n+    test \"$(echo $(cat foo))\" = \"0 1 2 3 4\" &&\n+    test \"$(echo $(git diff-files))\" = \"\"\n+'\n+\n+test_expect_success 'Delete --spill several patches' '\n+    stg delete --spill p2 p3 p1 &&\n+    test \"$(echo $(stg series))\" = \"> p0 - p5 - p6 - p7\" &&\n+    test \"$(echo $(cat foo))\" = \"0 1 2 3 4\" &&\n+    test \"$(echo $(git diff-files))\" = \"\"\n+'\n+\n+test_done\n"}]}