help = 'edit a patch description or diff'
usage = """%prog [options] [<patch>]
-Edit the given patch (defaulting to the current one) description,
-author information or its diff (if the '--diff' option is
-passed). Without any other option, the command invokes the editor with
-the patch description and diff in the form below:
+Edit the description and author information of the given patch (or the
+current patch if no patch name was given). With --diff, also edit the
+diff.
- Subject line
+The editor is invoked with the following contents:
- From: author information
+ From: A U Thor <author@example.com>
Date: creation date
Patch description
- Signed-off-by: author
+If --diff was specified, the diff appears at the bottom, after a
+separator:
+
+ ---
+
+ Diff text
Command-line options can be used to modify specific information
without invoking the editor.
these files using the '--file' and '--diff' options.
"""
+directory = DirectoryHasRepository()
options = [make_option('-d', '--diff',
- help = 'allow the editing of the patch diff',
+ help = 'edit the patch diff',
action = 'store_true'),
make_option('-f', '--file',
help = 'use FILE instead of invoking the editor'),
message, author_name, author_email, author_date, diff = parse_patch(f)
f.close()
+ out.start('Updating patch "%s"' % pname)
+
if options.diff:
git.switch(bottom)
try:
git.switch(top)
raise
- out.start('Updating patch "%s"' % pname)
crt_series.refresh_patch(message = message,
author_name = author_name,
author_email = author_email,
author_date = author_date,
backup = True, log = 'edit')
+
if crt_series.empty_patch(pname):
out.done('empty patch')
else:
# generate the file to be edited
descr = patch.get_description().strip()
- descr_lines = descr.split('\n')
authdate = patch.get_authdate()
- short_descr = descr_lines[0].rstrip()
- long_descr = reduce(lambda x, y: x + '\n' + y,
- descr_lines[1:], '').strip()
-
- tmpl = '%(shortdescr)s\n\n' \
- 'From: %(authname)s <%(authemail)s>\n'
+ tmpl = 'From: %(authname)s <%(authemail)s>\n'
if authdate:
tmpl += 'Date: %(authdate)s\n'
- tmpl += '\n%(longdescr)s\n'
+ tmpl += '\n%(descr)s\n'
tmpl_dict = {
- 'shortdescr': short_descr,
- 'longdescr': long_descr,
+ 'descr': descr,
'authname': patch.get_authname(),
'authemail': patch.get_authemail(),
'authdate': patch.get_authdate()