- """Pushes the given patch or all onto the series
- """
-
- check_local_changes()
- check_conflicts()
- check_head_top_equal(crt_series)
-
- unapplied = crt_series.get_unapplied()
- if not unapplied:
- raise CmdException, 'No more patches to push'
-
- if options.number:
- patches = unapplied[:options.number]
- elif options.all:
- patches = unapplied
- elif len(args) == 0:
- patches = [unapplied[0]]
+ """Pushes the given patches or the first unapplied onto the stack."""
+ stack = directory.repository.current_stack
+ iw = stack.repository.default_iw
+ clean_iw = (not options.keep and iw) or None
+ trans = transaction.StackTransaction(stack, 'pop',
+ check_clean_iw = clean_iw)
+
+ if not trans.unapplied:
+ raise common.CmdException('No patches to push')
+
+ if options.all:
+ patches = list(trans.unapplied)
+ elif options.number:
+ patches = trans.unapplied[:options.number]
+ elif not args:
+ patches = [trans.unapplied[0]]