[PATCH] Show patch content in description edit buffer
[stgit] / stgit / commands / imprt.py
index 43bd2f1..c6eaa04 100644 (file)
@@ -42,6 +42,12 @@ options = [make_option('-m', '--mail',
                        action = 'store_true'),
            make_option('-n', '--name',
                        help = 'use NAME as the patch name'),
+           make_option('-e', '--edit',
+                       help = 'invoke an editor for the patch description',
+                       action = 'store_true'),
+           make_option('-s', '--showpatch',
+                       help = 'show the patch content in the editor buffer',
+                       action = 'store_true'),
            make_option('-a', '--author', metavar = '"NAME <EMAIL>"',
                        help = 'use "NAME <EMAIL>" as the author details'),
            make_option('--authname',
@@ -145,10 +151,13 @@ def func(parser, options, args):
 
     if len(args) == 1:
         filename = args[0]
-        patch = os.path.basename(filename)
-    elif options.name:
+    else:
         filename = None
+
+    if options.name:
         patch = options.name
+    elif filename:
+        patch = os.path.basename(filename)
     else:
         raise CmdException, 'Unkown patch name'
 
@@ -166,6 +175,10 @@ def func(parser, options, args):
         message, author_name, author_email, author_date = \
                  __parse_patch(filename)
 
+    # new_patch() will invoke the editor in this case
+    if not message:
+        edit = False
+
     # override the automatically parsed settings
     if options.authname:
         author_name = options.authname
@@ -189,7 +202,8 @@ def func(parser, options, args):
     sys.stdout.flush()
 
     git.apply_patch(filename)
-    crt_series.refresh_patch()
+    crt_series.refresh_patch(edit = options.edit,
+                             show_patch = options.showpatch)
 
     print 'done'
     print_crt_patch()