From b85a27bc852a94855fc410a0921fcaef2d13506b Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Thu, 20 Mar 2008 23:12:33 +0000 Subject: [PATCH] Allow the synchronisation of the unapplied patches Organization: Straylight/Edgeware From: Catalin Marinas This is useful to avoid pushing patches when a sync operation failed and needs to be resumed. Signed-off-by: Catalin Marinas --- stgit/commands/sync.py | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/stgit/commands/sync.py b/stgit/commands/sync.py index 660ee41..e0c8c7d 100644 --- a/stgit/commands/sync.py +++ b/stgit/commands/sync.py @@ -38,7 +38,7 @@ The sync operation can be reverted for individual patches with --undo.""" directory = DirectoryGotoToplevel() options = [make_option('-a', '--all', - help = 'synchronise all the patches', + help = 'synchronise all the applied patches', action = 'store_true'), make_option('-B', '--ref-branch', help = 'syncronise patches with BRANCH'), @@ -112,7 +112,9 @@ def func(parser, options, args): if options.all: patches = applied elif len(args) != 0: - patches = parse_patches(args, applied, ordered = True) + unapplied = crt_series.get_unapplied() + patches = parse_patches(args, applied + unapplied, len(applied), + ordered = True) elif applied: patches = [crt_series.get_current()] else: @@ -129,16 +131,22 @@ def func(parser, options, args): raise CmdException, 'No common patches to be synchronised' # pop to the one before the first patch to be synchronised - popped = applied[applied.index(sync_patches[0]) + 1:] - if popped: - pop_patches(crt_series, popped[::-1]) + first_patch = sync_patches[0] + if first_patch in applied: + to_pop = applied[applied.index(first_patch) + 1:] + if to_pop: + pop_patches(crt_series, to_pop[::-1]) + popped = patches[patches.index(first_patch) + 1:] + else: + popped = patches - for p in sync_patches: + for p in patches: if p in popped: - # push to this patch - idx = popped.index(p) + 1 - push_patches(crt_series, popped[:idx]) - del popped[:idx] + # push this patch + push_patches(crt_series, [p]) + if p not in sync_patches: + # nothing to synchronise + continue # the actual sync out.start('Synchronising "%s"' % p) @@ -163,7 +171,3 @@ def func(parser, options, args): out.done('updated') else: out.done() - - # push the remaining patches - if popped: - push_patches(crt_series, popped) -- [mdw]