Mercurial > hg
changeset 21999:6ce282ed801e
cmdutil: introduce 'editform' to distinguish the purpose of commit text editing
This information will be used to switch '[committemplate] changeset'
definition according to its purpose in the subsequent patch.
This information also makes it easier to hook commit text editing only
in the specific cases.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Sat, 02 Aug 2014 21:46:26 +0900 |
parents | 739095270f48 |
children | 20fd00ee432e |
files | mercurial/cmdutil.py |
diffstat | 1 files changed, 13 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Tue Jul 22 22:40:16 2014 -0700 +++ b/mercurial/cmdutil.py Sat Aug 02 21:46:26 2014 +0900 @@ -109,7 +109,8 @@ (logfile, inst.strerror)) return message -def getcommiteditor(edit=False, finishdesc=None, extramsg=None, **opts): +def getcommiteditor(edit=False, finishdesc=None, extramsg=None, + editform='', **opts): """get appropriate commit message editor according to '--edit' option 'finishdesc' is a function to be called with edited commit message @@ -122,6 +123,9 @@ 'Leave message empty to abort commit' line. 'HG: ' prefix and EOL is automatically added. + 'editform' is a dot-separated list of names, to distinguish + the purpose of commit text editing. + 'getcommiteditor' returns 'commitforceeditor' regardless of 'edit', if one of 'finishdesc' or 'extramsg' is specified, because they are specific for usage in MQ. @@ -129,7 +133,10 @@ if edit or finishdesc or extramsg: return lambda r, c, s: commitforceeditor(r, c, s, finishdesc=finishdesc, - extramsg=extramsg) + extramsg=extramsg, + editform=editform) + elif editform: + return lambda r, c, s: commiteditor(r, c, s, editform=editform) else: return commiteditor @@ -2175,12 +2182,13 @@ lockmod.release(lock, wlock) return newid -def commiteditor(repo, ctx, subs): +def commiteditor(repo, ctx, subs, editform=''): if ctx.description(): return ctx.description() - return commitforceeditor(repo, ctx, subs) + return commitforceeditor(repo, ctx, subs, editform=editform) -def commitforceeditor(repo, ctx, subs, finishdesc=None, extramsg=None): +def commitforceeditor(repo, ctx, subs, finishdesc=None, extramsg=None, + editform=''): if not extramsg: extramsg = _("Leave message empty to abort commit.") tmpl = repo.ui.config('committemplate', 'changeset', '').strip()