X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/blobdiff_plain/bd427e467ee41df85a761d4d6001b5f3797644cd..6b1e01119114f9ebf4e047485f089b7c58823710:/stgit/commands/push.py diff --git a/stgit/commands/push.py b/stgit/commands/push.py index 71fe100..a636ad2 100644 --- a/stgit/commands/push.py +++ b/stgit/commands/push.py @@ -24,16 +24,16 @@ from stgit.utils import * from stgit import stack, git -help = 'push a patch on top of the series' -usage = """%prog [options] [ [...]] +help = 'push one or more patches onto of the stack' +usage = """%prog [options] [] [] [..] -Push a patch (defaulting to the first unapplied one) or range of -patches to the stack. The 'push' operation allows patch reordering by -commuting them with the three-way merge algorithm. If the result of -the 'push' operation is not acceptable or if there are too many -conflicts, the '--undo' option can be used to revert the patch and the -tree to the state before the operation. Conflicts raised during the -push operation have to be fixed and the 'resolved' command run. +Push one or more patches (defaulting to the first unapplied one) onto +the stack. The 'push' operation allows patch reordering by commuting +them with the three-way merge algorithm. If the result of the 'push' +operation is not acceptable or if there are too many conflicts, the +'--undo' option can be used to revert the last pushed patch. Conflicts +raised during the push operation have to be fixed and the 'resolved' +command run. The command also notifies when the patch becomes empty (fully merged upstream) or is modified (three-way merged) by the 'push' operation.""" @@ -43,9 +43,6 @@ options = [make_option('-a', '--all', action = 'store_true'), make_option('-n', '--number', type = 'int', help = 'push the specified number of patches'), - make_option('-t', '--to', metavar = 'PATCH1[:PATCH2]', - help = 'push all patches to PATCH1 or between ' - 'PATCH1 and PATCH2'), make_option('--reverse', help = 'push the patches in reverse order', action = 'store_true'), @@ -53,22 +50,13 @@ options = [make_option('-a', '--all', help = 'check for patches merged upstream', action = 'store_true'), make_option('--undo', - help = 'undo the last push operation', + help = 'undo the last patch pushing', action = 'store_true')] -def is_patch_appliable(p): - """See if patch exists, or is already applied. - """ - if p in applied: - raise CmdException, 'Patch "%s" is already applied' % p - if p not in unapplied: - raise CmdException, 'Patch "%s" does not exist' % p - def func(parser, options, args): """Pushes the given patch or all onto the series """ - global applied, unapplied # If --undo is passed, do the work and exit if options.undo: @@ -91,36 +79,18 @@ def func(parser, options, args): check_conflicts() check_head_top_equal() - applied = crt_series.get_applied() unapplied = crt_series.get_unapplied() if not unapplied: raise CmdException, 'No more patches to push' - if options.to: - boundaries = options.to.split(':') - if len(boundaries) == 1: - is_patch_appliable(boundaries[0]) - patches = unapplied[:unapplied.index(boundaries[0])+1] - elif len(boundaries) == 2: - is_patch_appliable(boundaries[0]) - is_patch_appliable(boundaries[1]) - lb = unapplied.index(boundaries[0]) - hb = unapplied.index(boundaries[1]) - if lb > hb: - raise CmdException, 'Patch "%s" after "%s"' \ - % (boundaries[0], boundaries[1]) - patches = unapplied[lb:hb+1] - else: - raise CmdException, 'incorrect parameters to "--to"' - elif options.number: + if options.number: patches = unapplied[:options.number] elif options.all: patches = unapplied elif len(args) == 0: patches = [unapplied[0]] else: - patches = args - map(is_patch_appliable, patches) + patches = parse_patches(args, unapplied) if patches == []: raise CmdException, 'No patches to push'