From 575c575ea43be1145e79e1cc5d66c2a102d94f7f Mon Sep 17 00:00:00 2001 From: Clark Williams Date: Sat, 17 Feb 2007 14:42:27 -0600 Subject: [PATCH] URL import for stgit Signed-off-by: Clark Williams Signed-off-by: Catalin Marinas --- stgit/commands/imprt.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/stgit/commands/imprt.py b/stgit/commands/imprt.py index 7ab0757..1c8339c 100644 --- a/stgit/commands/imprt.py +++ b/stgit/commands/imprt.py @@ -27,7 +27,7 @@ from stgit import stack, git help = 'import a GNU diff file as a new patch' -usage = """%prog [options] [] +usage = """%prog [options] [|] Create a new patch and apply the given GNU diff file (or the standard input). By default, the file name is used as the patch name but this @@ -53,6 +53,9 @@ options = [make_option('-m', '--mail', make_option('-s', '--series', help = 'import a series of patches', action = 'store_true'), + make_option('-u', '--url', + help = 'import a patch from a URL', + action = 'store_true'), make_option('-n', '--name', help = 'use NAME as the patch name'), make_option('-t', '--strip', @@ -358,6 +361,20 @@ def __import_mbox(filename, options): f.close() +def __import_url(url, options): + """Import a patch from a URL + """ + import urllib + import tempfile + + if not url: + parser.error('URL argument required') + + patch = os.path.basename(url) + file = os.path.join(tempfile.gettempdir(), patch) + urllib.urlretrieve(url, file) + __import_file(patch, file, options) + def func(parser, options, args): """Import a GNU diff file as a new patch """ @@ -377,6 +394,8 @@ def func(parser, options, args): __import_series(filename, options) elif options.mbox: __import_mbox(filename, options) + elif options.url: + __import_url(filename, options) else: if options.name: patch = options.name -- 2.11.0