comparison mercurial/cmdutil.py @ 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 244b177a152e
children 0b5d6c062774
comparison
equal deleted inserted replaced
21404:ca275f7ec576 21405:dcf20f244c2a
106 message = '\n'.join(util.readfile(logfile).splitlines()) 106 message = '\n'.join(util.readfile(logfile).splitlines())
107 except IOError, inst: 107 except IOError, inst:
108 raise util.Abort(_("can't read commit message '%s': %s") % 108 raise util.Abort(_("can't read commit message '%s': %s") %
109 (logfile, inst.strerror)) 109 (logfile, inst.strerror))
110 return message 110 return message
111
112 def getcommiteditor(edit=False, **opts):
113 """get appropriate commit message editor according to '--edit' option"""
114 if edit:
115 return commitforceeditor
116 else:
117 return commiteditor
111 118
112 def loglimit(opts): 119 def loglimit(opts):
113 """get the log limit according to option -l/--limit""" 120 """get the log limit according to option -l/--limit"""
114 limit = opts.get('limit') 121 limit = opts.get('limit')
115 if limit: 122 if limit: