X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/blobdiff_plain/7a6a45b5f1379466bd23b33a7feed47d0b8331b7..1de97e5f5e62a46d69515052a860138e417f149b:/stgit/commands/goto.py diff --git a/stgit/commands/goto.py b/stgit/commands/goto.py index b347920..66f49df 100644 --- a/stgit/commands/goto.py +++ b/stgit/commands/goto.py @@ -15,19 +15,22 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ -from optparse import OptionParser, make_option from stgit.commands import common from stgit.lib import transaction +from stgit import argparse +from stgit.argparse import opt -help = 'push or pop patches to the given one' -usage = """%prog [options] - +help = 'Push or pop patches to the given one' +kind = 'stack' +usage = [''] +description = """ Push/pop patches to/from the stack until the one given on the command -line becomes current. There is no '--undo' option for 'goto'. Use the -'push --undo' command for this.""" +line becomes current.""" + +args = [argparse.other_applied_patches, argparse.unapplied_patches] +options = argparse.keep_option() directory = common.DirectoryHasRepositoryLib() -options = [] def func(parser, options, args): if len(args) != 1: @@ -36,16 +39,20 @@ def func(parser, options, args): stack = directory.repository.current_stack iw = stack.repository.default_iw - trans = transaction.StackTransaction(stack, 'goto') + clean_iw = (not options.keep and iw) or None + trans = transaction.StackTransaction(stack, 'goto', + check_clean_iw = clean_iw) if patch in trans.applied: to_pop = set(trans.applied[trans.applied.index(patch)+1:]) assert not trans.pop_patches(lambda pn: pn in to_pop) elif patch in trans.unapplied: try: for pn in trans.unapplied[:trans.unapplied.index(patch)+1]: - trans.push_patch(pn, iw) + trans.push_patch(pn, iw, allow_interactive = True) except transaction.TransactionHalted: pass + elif patch in trans.hidden: + raise common.CmdException('Cannot goto a hidden patch') else: raise common.CmdException('Patch "%s" does not exist' % patch) return trans.run(iw)