changeset 21420:d009f6555b81

mq: fold the code path to invoke editor into specific logic (qnew) This factoring simplifies the succeeding patch to switch from "ui.edit()" to "getcommiteditor()" for qnew.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Sun, 11 May 2014 00:49:36 +0900
parents 272785489ed3
children 4941caa9f0f8
files hgext/mq.py
diffstat 1 files changed, 5 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Sun May 11 00:49:36 2014 +0900
+++ b/hgext/mq.py	Sun May 11 00:49:36 2014 +0900
@@ -1026,7 +1026,7 @@
            msg: a string or a no-argument function returning a string
         """
         msg = opts.get('msg')
-        editor = opts.get('editor')
+        edit = opts.get('edit')
         user = opts.get('user')
         date = opts.get('date')
         if date:
@@ -1081,10 +1081,11 @@
                         p.write("# Date %s %s\n\n" % date)
 
                 defaultmsg = "[mq]: %s" % patchfn
-                if editor:
-                    origeditor = editor
+                editor = False
+                if edit:
                     def desceditor(repo, ctx, subs):
-                        desc = origeditor(repo, ctx, subs)
+                        desc = self.ui.edit(ctx.description() + "\n",
+                                            ctx.user())
                         if desc.rstrip():
                             return desc
                         else:
@@ -2442,10 +2443,6 @@
     msg = cmdutil.logmessage(ui, opts)
     q = repo.mq
     opts['msg'] = msg
-    if opts.get('edit'):
-        def editor(repo, ctx, subs):
-            return ui.edit(ctx.description() + "\n", ctx.user())
-        opts['editor'] = editor
     setupheaderopts(ui, opts)
     q.new(repo, patch, *args, **opts)
     q.savedirty()