From patchwork Sat May 10 16:08:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [18, of, 19] mq: fold the code paths to invoke editor into specific logic (qrefresh/qfold) From: Katsunori FUJIWARA X-Patchwork-Id: 4720 Message-Id: <87dc4e9b6d12c91c485c.1399738133@feefifofum> To: mercurial-devel@selenic.com Date: Sun, 11 May 2014 01:08:53 +0900 # HG changeset patch # User FUJIWARA Katsunori # 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. 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: