- patches = parse_patches(args, all)
-
- # working with "topush" patches in reverse order might be a bit
- # more efficient for large series but the main reason is for the
- # "topop != topush" comparison to work
- patches.reverse()
-
- topush = []
- topop = []
-
- for p in patches:
- while p in applied:
- top = applied.pop()
- if not top in patches:
- topush.append(top)
- topop.append(top)
- topush = patches + topush
-
- # remove common patches to avoid unnecessary pop/push
- while topush and topop:
- if topush[-1] != topop[-1]:
- break
- topush.pop()
- topop.pop()
-
- # check whether the operation is really needed
- if topop != topush:
- if topop:
- pop_patches(crt_series, topop)
- if topush:
- topush.reverse()
- push_patches(crt_series, topush)
+ patches = common.parse_patches(args, stack.patchorder.all)
+
+ if not patches:
+ raise common.CmdException('No patches to float')
+
+ applied = [p for p in stack.patchorder.applied if p not in patches] + \
+ patches
+ unapplied = [p for p in stack.patchorder.unapplied if not p in patches]
+ hidden = list(stack.patchorder.hidden)
+
+ iw = stack.repository.default_iw
+ clean_iw = (not options.keep and iw) or None
+ trans = transaction.StackTransaction(stack, 'sink',
+ check_clean_iw = clean_iw)
+
+ try:
+ trans.reorder_patches(applied, unapplied, hidden, iw)
+ except transaction.TransactionHalted:
+ pass
+ return trans.run(iw)