Signed-off-by: Catalin Marinas <catalin.marinas@xxxxxxxxx> --- stgit/commands/float.py | 75 ++++++++++++++++++----------------------------- 1 files changed, 29 insertions(+), 46 deletions(-) diff --git a/stgit/commands/float.py b/stgit/commands/float.py index 7c3dcdf..f94de88 100644 --- a/stgit/commands/float.py +++ b/stgit/commands/float.py @@ -16,11 +16,11 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ -import sys, os +import sys from stgit.argparse import opt -from stgit.commands.common import * -from stgit.utils import * -from stgit import argparse, stack, git +from stgit.commands import common +from stgit.lib import transaction +from stgit import argparse help = 'Push patches to the top, even if applied' kind = 'stack' @@ -36,25 +36,20 @@ args = [argparse.patch_range(argparse.applied_patches, argparse.unapplied_patches)] options = [ opt('-s', '--series', action = 'store_true', - short = 'Rearrange according to a series file')] + short = 'Rearrange according to a series file') + ] + argparse.keep_option() -directory = DirectoryGotoToplevel(log = True) +directory = common.DirectoryHasRepositoryLib() def func(parser, options, args): - """Pops and pushed to make the named patch the topmost patch + """Reorder patches to make the named patch the topmost one. """ args_nr = len(args) if (options.series and args_nr > 1) \ or (not options.series and args_nr == 0): parser.error('incorrect number of arguments') - check_local_changes() - check_conflicts() - check_head_top_equal(crt_series) - - unapplied = crt_series.get_unapplied() - applied = crt_series.get_applied() - all = unapplied + applied + stack = directory.repository.current_stack if options.series: if args_nr: @@ -68,35 +63,23 @@ def func(parser, options, args): if patch: patches.append(patch) else: - 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 p not 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) -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html