X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/stgit/blobdiff_plain/c70a7b27b0804ff978947be823effc6c954ea6a6..625e8de7db58c85f137e78aaef258afcb1a3151c:/stgit/commands/sync.py diff --git a/stgit/commands/sync.py b/stgit/commands/sync.py index 35c5c31..966ac55 100644 --- a/stgit/commands/sync.py +++ b/stgit/commands/sync.py @@ -16,37 +16,32 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ 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] [] [] [..] - +help = 'Synchronise patches with a branch or a series' +kind = 'patch' +usage = ['[options] [] [] [..]'] +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() @@ -68,18 +63,6 @@ def __series_merge_patch(base, patchdir, pname): 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(): @@ -136,11 +119,13 @@ def func(parser, options, args): 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]) @@ -155,8 +140,7 @@ def func(parser, options, args): 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)