X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/blobdiff_plain/2cf7e94e933bf3e8091622d7d6730e145cc9bf64..b75457e8b8dff6ed3aa50c91766b72d43f385b0f:/stgit/commands/goto.py diff --git a/stgit/commands/goto.py b/stgit/commands/goto.py index e129b8d..84b840b 100644 --- a/stgit/commands/goto.py +++ b/stgit/commands/goto.py @@ -27,11 +27,13 @@ help = 'push or pop patches to the given one' usage = """%prog [options] Push/pop patches to/from the stack until the one given on the command -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.""" +line becomes current. There is no '--undo' option for 'goto'. Use the +'push --undo' command for this.""" -options = [] +directory = DirectoryGotoToplevel() +options = [make_option('-k', '--keep', + help = 'keep the local changes when popping patches', + action = 'store_true')] def func(parser, options, args): @@ -40,9 +42,11 @@ def func(parser, options, args): if len(args) != 1: parser.error('incorrect number of arguments') - check_local_changes() check_conflicts() - check_head_top_equal() + check_head_top_equal(crt_series) + + if not options.keep: + check_local_changes() applied = crt_series.get_applied() unapplied = crt_series.get_unapplied() @@ -51,11 +55,13 @@ def func(parser, options, args): if patch in applied: applied.reverse() patches = applied[:applied.index(patch)] - pop_patches(patches) + pop_patches(crt_series, 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) + push_patches(crt_series, patches) else: raise CmdException, 'Patch "%s" does not exist' % patch - print_crt_patch() + print_crt_patch(crt_series)