From: David Kågedal Date: Tue, 11 Dec 2007 11:00:16 +0000 (+0100) Subject: Added --save-template flag to edit command X-Git-Tag: v0.15-rc1~365 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/stgit/commitdiff_plain/3cbb569f920044068317ddd0dee747e5d021a38f Added --save-template flag to edit command Signed-off-by: David Kågedal Signed-off-by: Karl Hasselström --- diff --git a/stgit/commands/edit.py b/stgit/commands/edit.py index a4d8f96..ec2c4ae 100644 --- a/stgit/commands/edit.py +++ b/stgit/commands/edit.py @@ -72,6 +72,8 @@ options = [make_option('-d', '--diff', help = 'annotate the patch log entry'), make_option('-m', '--message', help = 'replace the patch description with MESSAGE'), + make_option('--save-template', metavar = 'FILE', + help = 'save the patch to FILE in the format used by -f'), make_option('--author', metavar = '"NAME "', help = 'replae the author details with "NAME "'), make_option('--authname', @@ -120,8 +122,8 @@ def __update_patch(pname, fname, options): else: out.done() -def __edit_update_patch(pname, options): - """Edit the given patch interactively. +def __generate_file(pname, fname, options): + """Generate a file containing the description to edit """ patch = crt_series.get_patch(pname) @@ -168,15 +170,20 @@ def __edit_update_patch(pname, options): text = tmpl % tmpl_dict + # write the file to be edited + f = open(fname, 'w+') + f.write(text) + f.close() + +def __edit_update_patch(pname, options): + """Edit the given patch interactively. + """ if options.diff: fname = '.stgit-edit.diff' else: fname = '.stgit-edit.txt' - # write the file to be edited - f = open(fname, 'w+') - f.write(text) - f.close() + __generate_file(pname, fname, options) # invoke the editor call_editor(fname) @@ -233,6 +240,8 @@ def func(parser, options, args): log = 'edit', notes = options.annotate) out.done() + elif options.save_template: + __generate_file(pname, options.save_template, options) elif options.file: __update_patch(pname, options.file, options) else: