From 42fc7623404159ca33ba5ef1bd74ca4c339d827a Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Fri, 24 Nov 2006 22:57:55 +0000 Subject: [PATCH] Allows to refresh a non-top applied patch. Signed-off-by: Yann Dirson --- stgit/commands/refresh.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/stgit/commands/refresh.py b/stgit/commands/refresh.py index 2949ecb..2d164cd 100644 --- a/stgit/commands/refresh.py +++ b/stgit/commands/refresh.py @@ -66,6 +66,8 @@ options = [make_option('-f', '--force', make_option('--commemail', help = 'use COMMEMAIL as the committer ' \ 'e-mail'), + make_option('-p', '--patch', + help = 'refresh (applied) PATCH instead of the top one'), make_option('--sign', help = 'add Signed-off-by line', action = 'store_true'), @@ -80,9 +82,17 @@ def func(parser, options, args): if autoresolved != 'yes': check_conflicts() - patch = crt_series.get_current() - if not patch: - raise CmdException, 'No patches applied' + if options.patch: + if args: + raise CmdException, \ + 'Only full refresh is available with the --patch option' + patch = options.patch + if not crt_series.patch_applied(patch): + raise CmdException, 'Patches "%s" not applied' % patch + else: + patch = crt_series.get_current() + if not patch: + raise CmdException, 'No patches applied' if not options.force: check_head_top_equal() @@ -112,6 +122,12 @@ def func(parser, options, args): or options.authname or options.authemail or options.authdate \ or options.commname or options.commemail \ or options.sign or options.ack: + + if options.patch: + applied = crt_series.get_applied() + between = applied[:applied.index(patch):-1] + pop_patches(between, keep = True) + print 'Refreshing patch "%s"...' % patch, sys.stdout.flush() @@ -128,6 +144,10 @@ def func(parser, options, args): committer_email = options.commemail, backup = True, sign_str = sign_str) + if options.patch: + between.reverse() + push_patches(between) + print 'done' else: print 'Patch "%s" is already up to date' % patch -- 2.11.0