Mercurial > hg
changeset 21405:dcf20f244c2a
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).
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Sun, 11 May 2014 00:49:35 +0900 |
parents | ca275f7ec576 |
children | 288a793c3167 |
files | mercurial/cmdutil.py |
diffstat | 1 files changed, 7 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Wed May 14 12:49:55 2014 -0700 +++ b/mercurial/cmdutil.py Sun May 11 00:49:35 2014 +0900 @@ -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')