Patchwork [18,of,19] mq: fold the code paths to invoke editor into specific logic (qrefresh/qfold)

login
register
mail settings
Submitter Katsunori FUJIWARA
Date May 10, 2014, 4:08 p.m.
Message ID <87dc4e9b6d12c91c485c.1399738133@feefifofum>
Download mbox | patch
Permalink /patch/4720/
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 87dc4e9b6d12c91c485c33ce32043ac41dd80fcf
# Parent  0cba86ca33859c9a8de398ad170c315702fd27c6
mq: fold the code paths to invoke editor into specific logic (qrefresh/qfold)

This factoring simplifies the succeeding patch to switch from
"ui.edit()" to "getcommiteditor()" for qrefresh/qfold.

Patch

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -1486,7 +1486,7 @@ 
             self.ui.write(_("no patches applied\n"))
             return 1
         msg = opts.get('msg', '').rstrip()
-        editor = opts.get('editor')
+        edit = opts.get('edit')
         newuser = opts.get('user')
         newdate = opts.get('date')
         if newdate:
@@ -1656,10 +1656,11 @@ 
                 # might be nice to attempt to roll back strip after this
 
                 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():
                             ph.setmessage(desc)
                             return desc
@@ -2490,14 +2491,10 @@ 
     if opts.get('edit'):
         if message:
             raise util.Abort(_('option "-e" incompatible with "-m" or "-l"'))
-        def editor(repo, ctx, subs):
-            return ui.edit(ctx.description() + "\n", ctx.user())
-    else:
-        editor = False
     setupheaderopts(ui, opts)
     wlock = repo.wlock()
     try:
-        ret = q.refresh(repo, pats, msg=message, editor=editor, **opts)
+        ret = q.refresh(repo, pats, msg=message, **opts)
         q.savedirty()
         return ret
     finally:
@@ -2587,16 +2584,10 @@ 
                 message.extend(msg)
         message = '\n'.join(message)
 
-    if opts.get('edit'):
-        def editor(repo, ctx, subs):
-            return ui.edit(ctx.description() + "\n", ctx.user())
-    else:
-        editor = False
-
     diffopts = q.patchopts(q.diffopts(), *patches)
     wlock = repo.wlock()
     try:
-        q.refresh(repo, msg=message, git=diffopts.git, editor=editor)
+        q.refresh(repo, msg=message, git=diffopts.git, edit=opts.get('edit'))
         q.delete(repo, patches, opts)
         q.savedirty()
     finally: