as per ML suggestion

Signed-off-by: Vincent Legoll <[email protected]>
---
 stgit/commands/pop.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/stgit/commands/pop.py b/stgit/commands/pop.py
index 5c10b9e..71cded5 100644
--- a/stgit/commands/pop.py
+++ b/stgit/commands/pop.py
@@ -37,6 +37,8 @@ args = [argparse.patch_range(argparse.applied_patches)]
 options = [
     opt('-a', '--all', action = 'store_true',
         short = 'Pop all the applied patches'),
+    opt('-s', '--spill', action = 'store_true',
+        short = 'Pop a patch, keeping its modifications in the tree'),
     opt('-n', '--number', type = 'int',
         short = 'Pop the specified number of patches', long = '''
         Pop the specified number of patches.
@@ -50,7 +52,7 @@ def func(parser, options, args):
     """Pop the given patches or the topmost one from the stack."""
     stack = directory.repository.current_stack
     iw = stack.repository.default_iw
-    clean_iw = (not options.keep and iw) or None
+    clean_iw = (not options.keep and not options.spill and iw) or None
     trans = transaction.StackTransaction(stack, 'pop',
                                          check_clean_iw = clean_iw)
 
@@ -73,8 +75,14 @@ def func(parser, options, args):
         patches = common.parse_patches(args, trans.applied, ordered = True)
 
     if not patches:
+               #FIXME: Why is this an error, and not just a noop ?
         raise common.CmdException('No patches to pop')
 
+    if options.spill:
+        if set(stack.patchorder.applied[-len(patches):]) != set(patches):
+            parser.error('Can only spill topmost applied patches')
+        iw = None # don't touch index+worktree
+
     applied = [p for p in trans.applied if not p in set(patches)]
     unapplied = patches + trans.unapplied
     try:
-- 
2.1.4


_______________________________________________
stgit-users mailing list
[email protected]
https://mail.gna.org/listinfo/stgit-users

Reply via email to