From: David Kågedal Date: Mon, 10 Dec 2007 21:43:55 +0000 (+0100) Subject: Treat filename '-' as stdin/stdout in edit X-Git-Tag: v0.15-rc1~364 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/stgit/commitdiff_plain/8a88f7cb553d1ff6f1aa5327a27aeb3eecc49e78 Treat filename '-' as stdin/stdout in edit 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 ec2c4ae..4d1475f 100644 --- a/stgit/commands/edit.py +++ b/stgit/commands/edit.py @@ -96,7 +96,10 @@ def __update_patch(pname, fname, options): bottom = patch.get_bottom() top = patch.get_top() - f = open(fname) + if fname == '-': + f = sys.stdin + else: + f = open(fname) message, author_name, author_email, author_date, diff = parse_patch(f) f.close() @@ -171,9 +174,12 @@ def __generate_file(pname, fname, options): text = tmpl % tmpl_dict # write the file to be edited - f = open(fname, 'w+') - f.write(text) - f.close() + if fname == '-': + sys.stdout.write(text) + else: + f = open(fname, 'w+') + f.write(text) + f.close() def __edit_update_patch(pname, options): """Edit the given patch interactively.