chiark / gitweb /
Add --keep option to goto
authorCatalin Marinas <catalin.marinas@gmail.com>
Fri, 13 Jul 2007 22:43:55 +0000 (23:43 +0100)
committerCatalin Marinas <catalin.marinas@gmail.com>
Fri, 13 Jul 2007 22:43:55 +0000 (23:43 +0100)
This option is similar to the one for the pop command.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
stgit/commands/goto.py

index e129b8db1b43f80fd038c656a3c66d061dc1e85e..a4427faae58d6415611bceb7c48771586cca9aec 100644 (file)
@@ -31,7 +31,9 @@ line becomes current. This is a shortcut for the 'push --to' or 'pop
 --to' commands. There is no '--undo' option for 'goto'. Use the 'push'
 command for this."""
 
-options = []
+options = [make_option('-k', '--keep',
+                       help = 'keep the local changes when popping patches',
+                       action = 'store_true')]
 
 
 def func(parser, options, args):
@@ -40,10 +42,12 @@ def func(parser, options, args):
     if len(args) != 1:
         parser.error('incorrect number of arguments')
 
-    check_local_changes()
     check_conflicts()
     check_head_top_equal()
 
+    if not options.keep:
+        check_local_changes()
+
     applied = crt_series.get_applied()
     unapplied = crt_series.get_unapplied()
     patch = args[0]
@@ -51,8 +55,10 @@ def func(parser, options, args):
     if patch in applied:
         applied.reverse()
         patches = applied[:applied.index(patch)]
-        pop_patches(patches)
+        pop_patches(patches, options.keep)
     elif patch in unapplied:
+        if options.keep:
+            raise CmdException, 'Cannot use --keep with patch pushing'
         patches = unapplied[:unapplied.index(patch)+1]
         push_patches(patches)
     else: