Patchwork [16,of,19] mq: fold the code path to invoke editor into specific logic (qnew)

login
register
mail settings
Submitter Katsunori FUJIWARA
Date May 10, 2014, 4:08 p.m.
Message ID <73f1b585d9440c53a962.1399738131@feefifofum>
Download mbox | patch
Permalink /patch/4718/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - May 10, 2014, 4:08 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1399736976 -32400
#      Sun May 11 00:49:36 2014 +0900
# Node ID 73f1b585d9440c53a962af3cd8ef4d4c085f0788
# Parent  4b998ec208e265de4c981645536c94b2536afa9a
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.

Patch

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -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()