From 8a88f7cb553d1ff6f1aa5327a27aeb3eecc49e78 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20K=C3=A5gedal?= Date: Mon, 10 Dec 2007 22:43:55 +0100 Subject: [PATCH] Treat filename '-' as stdin/stdout in edit MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: David Kågedal Signed-off-by: Karl Hasselström --- stgit/commands/edit.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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. -- 2.11.0