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.
--- 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()