"""
import sys, os
-from optparse import OptionParser, make_option
-
+from stgit.argparse import opt
from stgit.commands.common import *
from stgit.utils import *
-from stgit import stack, git
-
-help = 'push patches to the top, even if applied'
-usage = """%prog [<patches> | -s [<series>] ]
+from stgit import argparse, stack, git
+help = 'Push patches to the top, even if applied'
+kind = 'stack'
+usage = ['<patches>',
+ '-s <series>']
+description = """
Push a patch or a range of patches to the top even if applied. The
necessary pop and push operations will be performed to accomplish
this. The '--series' option can be used to rearrange the (top) patches
as specified by the given series file (or the standard input)."""
-directory = DirectoryGotoToplevel()
-options = [make_option('-s', '--series',
- help = 'rearrange according to a series file',
- action = 'store_true')]
+args = [argparse.patch_range(argparse.applied_patches,
+ argparse.unapplied_patches)]
+options = [
+ opt('-s', '--series', action = 'store_true',
+ short = 'Rearrange according to a series file')]
+
+directory = DirectoryGotoToplevel(log = True)
def func(parser, options, args):
"""Pops and pushed to make the named patch the topmost patch
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: