- if patch in applied:
- applied.reverse()
- patches = applied[:applied.index(patch)]
- 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(crt_series, patches)
+ stack = directory.repository.current_stack
+ iw = stack.repository.default_iw
+ 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:
+ to_push = trans.unapplied[:trans.unapplied.index(patch)+1]
+ if options.merged:
+ merged = set(trans.check_merged(to_push))
+ else:
+ merged = set()
+ for pn in to_push:
+ trans.push_patch(pn, iw, allow_interactive = True,
+ already_merged = pn in merged)
+ except transaction.TransactionHalted:
+ pass
+ elif patch in trans.hidden:
+ raise common.CmdException('Cannot goto a hidden patch')