Patchwork [01,of,19] cmdutil: introduce "getcommiteditor()" to simplify code paths to choose editor

login
register
mail settings
Submitter Katsunori FUJIWARA
Date May 10, 2014, 4:08 p.m.
Message ID <b482c1575fdf145f0328.1399738116@feefifofum>
Download mbox | patch
Permalink /patch/4703/
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 1399736975 -32400
#      Sun May 11 00:49:35 2014 +0900
# Node ID b482c1575fdf145f03285a6a846b7f07a753b8a2
# Parent  bcddddcf0b540b1d98f0dc1f1a1bef9337e2e567
cmdutil: introduce "getcommiteditor()" to simplify code paths to choose editor

"getcommiteditor()" can simplify code paths to choose commit editor
according to '--edit' option as below:

    before:
        editor = cmdutil.commiteditor # or editor = None/False
        if opts.get('edit'):
            editor = cmdutil.commitforceeditor

    after:
        editor = cmdutil.getcommiteditor(**opts)

"getcommiteditor()" accepts option arguments not in "opts" style but
in "**opts" style, because some code paths want to invoke it with just
explicit "edit=True" argument (building dictionary is redundant).
Katsunori FUJIWARA - May 11, 2014, 9:14 a.m.
At Sun, 11 May 2014 01:08:36 +0900,
FUJIWARA Katsunori wrote:
> 
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> # Date 1399736975 -32400
> #      Sun May 11 00:49:35 2014 +0900
> # Node ID b482c1575fdf145f03285a6a846b7f07a753b8a2
> # Parent  bcddddcf0b540b1d98f0dc1f1a1bef9337e2e567
> cmdutil: introduce "getcommiteditor()" to simplify code paths to choose editor

Oops, sorry for violation of "around 6 patches" in "Flow control"
guideline.

    http://mercurial.selenic.com/wiki/ContributingChanges#Flow_control

Please ignore this series, and I'll re-send a part of grouped ones.

----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy@lares.dti.ne.jp
Pierre-Yves David - May 11, 2014, 9:17 a.m.
On 05/11/2014 02:14 AM, FUJIWARA Katsunori wrote:
>
> At Sun, 11 May 2014 01:08:36 +0900,
> FUJIWARA Katsunori wrote:
>>
>> # HG changeset patch
>> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
>> # Date 1399736975 -32400
>> #      Sun May 11 00:49:35 2014 +0900
>> # Node ID b482c1575fdf145f03285a6a846b7f07a753b8a2
>> # Parent  bcddddcf0b540b1d98f0dc1f1a1bef9337e2e567
>> cmdutil: introduce "getcommiteditor()" to simplify code paths to choose editor
>
> Oops, sorry for violation of "around 6 patches" in "Flow control"
> guideline.
>
>      http://mercurial.selenic.com/wiki/ContributingChanges#Flow_control
>
> Please ignore this series, and I'll re-send a part of grouped ones.

Well, now that it's done I'll probably look at it. 19 is not apocalyptic 
if you kept them trivial. And you already have a lot of contributor 
credit in your account.
Katsunori FUJIWARA - May 11, 2014, 9:57 a.m.
At Sun, 11 May 2014 02:17:49 -0700,
Pierre-Yves David wrote:
> 
> On 05/11/2014 02:14 AM, FUJIWARA Katsunori wrote:
> >
> > At Sun, 11 May 2014 01:08:36 +0900,
> > FUJIWARA Katsunori wrote:
> >>
> >> # HG changeset patch
> >> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> >> # Date 1399736975 -32400
> >> #      Sun May 11 00:49:35 2014 +0900
> >> # Node ID b482c1575fdf145f03285a6a846b7f07a753b8a2
> >> # Parent  bcddddcf0b540b1d98f0dc1f1a1bef9337e2e567
> >> cmdutil: introduce "getcommiteditor()" to simplify code paths to choose editor
> >
> > Oops, sorry for violation of "around 6 patches" in "Flow control"
> > guideline.
> >
> >      http://mercurial.selenic.com/wiki/ContributingChanges#Flow_control
> >
> > Please ignore this series, and I'll re-send a part of grouped ones.
> 
> Well, now that it's done I'll probably look at it. 19 is not apocalyptic 
> if you kept them trivial. And you already have a lot of contributor 
> credit in your account.

Thanks !

I update the status of them in patchwork back to "new", and avoid
redundant re-sending a part of them to devel-ml.


> -- 
> Pierre-Yves
> 

----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy@lares.dti.ne.jp

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -109,6 +109,13 @@ 
                              (logfile, inst.strerror))
     return message
 
+def getcommiteditor(edit=False, **opts):
+    """get appropriate commit message editor according to '--edit' option"""
+    if edit:
+        return commitforceeditor
+    else:
+        return commiteditor
+
 def loglimit(opts):
     """get the log limit according to option -l/--limit"""
     limit = opts.get('limit')