"""
import sys, os
-from optparse import OptionParser, make_option
-
import stgit.commands.common
+from stgit.argparse import opt
from stgit.commands.common import *
from stgit.utils import *
from stgit.out import *
from stgit import stack, git
-
-help = 'synchronise patches with a branch or a series'
-usage = """%prog [options] [<patch1>] [<patch2>] [<patch3>..<patch4>]
-
+help = 'Synchronise patches with a branch or a series'
+kind = 'patch'
+usage = ['[options] [<patch1>] [<patch2>] [<patch3>..<patch4>]']
+description = """
For each of the specified patches perform a three-way merge with the
same patch in the specified branch or series. The command can be used
for keeping patches on several branches in sync. Note that the
operation may fail for some patches because of conflicts. The patches
-in the series must apply cleanly.
-
-The sync operation can be reverted for individual patches with --undo."""
-
-directory = DirectoryGotoToplevel()
-options = [make_option('-a', '--all',
- help = 'synchronise all the applied patches',
- action = 'store_true'),
- make_option('-B', '--ref-branch',
- help = 'syncronise patches with BRANCH'),
- make_option('-s', '--series',
- help = 'syncronise patches with SERIES'),
- make_option('--undo',
- help = 'undo the synchronisation of the current patch',
- action = 'store_true')]
+in the series must apply cleanly."""
+
+options = [
+ opt('-a', '--all', action = 'store_true',
+ short = 'Synchronise all the applied patches'),
+ opt('-B', '--ref-branch',
+ short = 'Syncronise patches with BRANCH'),
+ opt('-s', '--series',
+ short = 'Syncronise patches with SERIES')]
+
+directory = DirectoryGotoToplevel(log = True)
def __check_all():
check_local_changes()
def func(parser, options, args):
"""Synchronise a range of patches
"""
- if options.undo:
- if options.ref_branch or options.series:
- raise CmdException, \
- '--undo cannot be specified with --ref-branch or --series'
- __check_all()
-
- out.start('Undoing the sync of "%s"' % crt_series.get_current())
- crt_series.undo_refresh()
- git.reset()
- out.done()
- return
-
if options.ref_branch:
remote_series = stack.Series(options.ref_branch)
if options.ref_branch == crt_series.get_name():
to_pop = applied[applied.index(first_patch) + 1:]
if to_pop:
pop_patches(crt_series, to_pop[::-1])
+ pushed = [first_patch]
else:
to_pop = []
+ pushed = []
popped = to_pop + [p for p in patches if p in unapplied]
- for p in [first_patch] + popped:
+ for p in pushed + popped:
if p in popped:
# push this patch
push_patches(crt_series, [p])
bottom = patch.get_bottom()
top = patch.get_top()
- # reset the patch backup information. That's needed in case we
- # undo the sync but there were no changes made
+ # reset the patch backup information.
patch.set_top(top, backup = True)
# the actual merging (either from a branch or an external file)