make_option('-s', '--showpatch',
help = 'show the patch content in the editor buffer',
action = 'store_true'),
+ make_option('--update',
+ help = 'only update the current patch files',
+ action = 'store_true'),
make_option('--undo',
help = 'revert the commit generated by the last refresh',
action = 'store_true'),
make_option('-m', '--message',
help = 'use MESSAGE as the patch ' \
'description'),
- make_option('-a', '--author', metavar = '"NAME <EMAIL>"',
+ make_option('-a', '--annotate', metavar = 'NOTE',
+ help = 'annotate the patch log entry'),
+ make_option('--author', metavar = '"NAME <EMAIL>"',
help = 'use "NAME <EMAIL>" as the author details'),
make_option('--authname',
help = 'use AUTHNAME as the author name'),
help = 'use COMMNAME as the committer name'),
make_option('--commemail',
help = 'use COMMEMAIL as the committer ' \
- 'e-mail')]
+ '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'),
+ make_option('--ack',
+ help = 'add Acked-by line',
+ action = 'store_true')]
def func(parser, options, args):
- autoresolved = config.get('stgit', 'autoresolved')
+ autoresolved = config.get('stgit.autoresolved')
if autoresolved != 'yes':
check_conflicts()
- patch = crt_series.get_current()
- if not patch:
- raise CmdException, 'No patches applied'
+ if options.patch:
+ if args or options.update:
+ 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()
if options.undo:
- print 'Undoing the "%s" refresh...' % patch,
- sys.stdout.flush()
+ out.start('Undoing the refresh of "%s"' % patch)
crt_series.undo_refresh()
- print 'done'
+ out.done()
return
if options.author:
options.authname, options.authemail = name_email(options.author)
- if git.local_changes() \
- or not crt_series.head_top_equal() \
+ if options.sign:
+ sign_str = 'Signed-off-by'
+ if options.ack:
+ raise CmdException, '--ack and --sign were both specified'
+ elif options.ack:
+ sign_str = 'Acked-by'
+ else:
+ sign_str = None
+
+ files = [x[1] for x in git.tree_status(verbose = True)]
+ if args:
+ files = [f for f in files if f in args]
+
+ if files or not crt_series.head_top_equal() \
or options.edit or options.message \
or options.authname or options.authemail or options.authdate \
- or options.commname or options.commemail:
- print 'Refreshing patch "%s"...' % patch,
- sys.stdout.flush()
+ or options.commname or options.commemail \
+ or options.sign or options.ack or options.annotate:
+
+ if options.patch:
+ applied = crt_series.get_applied()
+ between = applied[:applied.index(patch):-1]
+ pop_patches(between, keep = True)
+ elif options.update:
+ rev1 = git_id('//bottom')
+ rev2 = git_id('//top')
+ patch_files = git.barefiles(rev1, rev2).split('\n')
+ files = [f for f in files if f in patch_files]
+ if not files:
+ out.info('No modified files for updating patch "%s"' % patch)
+ return
+
+ out.start('Refreshing patch "%s"' % patch)
if autoresolved == 'yes':
resolved_all()
- crt_series.refresh_patch(files = args,
+ crt_series.refresh_patch(files = files,
message = options.message,
edit = options.edit,
show_patch = options.showpatch,
author_date = options.authdate,
committer_name = options.commname,
committer_email = options.commemail,
- backup = True)
+ backup = True, sign_str = sign_str,
+ notes = options.annotate)
+
+ if crt_series.empty_patch(patch):
+ out.done('empty patch')
+ else:
+ out.done()
- print 'done'
+ if options.patch:
+ between.reverse()
+ push_patches(between)
else:
- print 'Patch "%s" is already up to date' % patch
+ out.info('Patch "%s" is already up to date' % patch)