chiark / gitweb /
[PATCH] Really fix import --edit invoking editor twice
authorPaolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Fri, 2 Sep 2005 09:25:30 +0000 (11:25 +0200)
committerCatalin Marinas <catalin.marinas@gmail.com>
Fri, 2 Sep 2005 16:17:25 +0000 (17:17 +0100)
A typo prevented the previous patch for this (commit
9d15ccd85e36ef5cd554aaf98f1c37ef0433697f) from working (edit is never used,
you should have set options.edit). Ah, nice Python! No var declarations and
these are the effects (yes, I reproduced this).

However, if the description is left empty, refresh_patch will again invoke
the editor. Also, with --showpatch, the first invocation shows the topmost
patch, not the one to be imported.

So better stop new_patch from invoking the editor, and call it only on
refresh.

Btw, clean the old unused "edit" parameter of Series.new_patch.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
stgit/commands/imprt.py
stgit/stack.py

index c6eaa0411468d05492aa803ab201744c8ad5a1ad..e75536bf51333a5662cf3e6ce755a289ec5ae4df 100644 (file)
@@ -175,9 +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
+    # refresh_patch() will invoke the editor in this case, with correct
+    # patch content
     if not message:
-        edit = False
+        can_edit = False
 
     # override the automatically parsed settings
     if options.authname:
@@ -191,7 +192,7 @@ def func(parser, options, args):
     if options.commemail:
         committer_email = options.commemail
 
-    crt_series.new_patch(patch, message = message,
+    crt_series.new_patch(patch, message = message, can_edit = False,
                          author_name = author_name,
                          author_email = author_email,
                          author_date = author_date,
index 1e45e72a239a899bf94e5a20cf6c8fe84e53c13d..8970c04cda8bde7daa8cd3d6ea433eeb6de9ab5d 100644 (file)
@@ -406,7 +406,7 @@ class Series:
 
         return commit_id
 
-    def new_patch(self, name, message = None, edit = False, show_patch = False,
+    def new_patch(self, name, message = None, can_edit = True, show_patch = False,
                   author_name = None, author_email = None, author_date = None,
                   committer_name = None, committer_email = None):
         """Creates a new patch
@@ -414,7 +414,7 @@ class Series:
         if self.__patch_applied(name) or self.__patch_unapplied(name):
             raise StackException, 'Patch "%s" already exists' % name
 
-        if not message:
+        if not message and can_edit:
             descr = edit_file(self, None, \
                               'Please enter the description for patch "%s" ' \
                               'above.' % name, show_patch)