help = 'push a patch on top of the series'
-usage = '%prog [options] [<name>]'
+usage = """%prog [options] [<name>]
+
+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.
+
+The 'push' command also notifies when the patch becomes empty after
+the merge operation (i.e. it was fully merged upstream)."""
options = [make_option('-a', '--all',
help = 'push all the unapplied patches',
print 'Undoing the "%s" push...' % patch,
sys.stdout.flush()
resolved_all()
- crt_series.undo_push()
- print 'done'
+ if crt_series.undo_push():
+ print 'done'
+ else:
+ print 'done (patch unchanged)'
print_crt_patch()
return
elif len(args) == 0:
patches = [unapplied[0]]
elif len(args) == 1:
- patches = [args[0]]
+ patches = args
+ if patches[0] not in unapplied:
+ raise CmdException, 'Patch "%s" not unapplied' % patches[0]
else:
parser.error('incorrect number of arguments')
if options.reverse:
patches.reverse()
- for p in patches:
+ print 'Trying fast-forward...'
+
+ forwarded = crt_series.forward_patches(patches)
+ if forwarded > 1:
+ print 'Fast-forwarded patches "%s" - "%s"' % (patches[0],
+ patches[forwarded - 1])
+ elif forwarded == 1:
+ print 'Fast-forwarded patch "%s"' % patches[0]
+ else:
+ print 'Fast-forwarding failed, using normal pushing'
+
+ for p in patches[forwarded:]:
+ if p not in unapplied:
+ raise CmdException, 'Patch "%s" not unapplied' % p
+
print 'Pushing patch "%s"...' % p,
sys.stdout.flush()