2016-10-03 14:39:51 +03:00
|
|
|
from mercurial import (
|
|
|
|
cmdutil,
|
|
|
|
context,
|
|
|
|
error,
|
2017-05-22 23:38:37 +03:00
|
|
|
registrar,
|
2016-10-03 14:39:51 +03:00
|
|
|
)
|
|
|
|
from mercurial.i18n import _
|
|
|
|
|
|
|
|
cmdtable = {}
|
2017-05-22 23:38:37 +03:00
|
|
|
command = registrar.command(cmdtable)
|
2016-10-03 14:39:51 +03:00
|
|
|
|
|
|
|
@command('debugcommitmessage', [], _('FORM'))
|
|
|
|
def debugcommitmessage(ui, repo, *args):
|
|
|
|
form = None
|
|
|
|
if len(args) > 1:
|
|
|
|
raise error.Abort(_('provide at most one form'))
|
|
|
|
elif len(args) > 0:
|
|
|
|
form = args[0]
|
|
|
|
|
|
|
|
status = repo.status()
|
|
|
|
text = ''
|
|
|
|
user = None
|
|
|
|
date = None
|
|
|
|
extra = None
|
|
|
|
|
|
|
|
ctx = context.workingcommitctx(repo, status, text, user, date, extra)
|
|
|
|
|
|
|
|
subs = []
|
|
|
|
editform = form or 'commit.normal.normal'
|
|
|
|
extramsg = _('Leave message empty to abort commit.')
|
|
|
|
|
|
|
|
forms = [e for e in editform.split('.') if e]
|
|
|
|
forms.insert(0, 'changeset')
|
|
|
|
while forms:
|
2017-06-19 13:01:18 +03:00
|
|
|
ref = '.'.join(forms)
|
|
|
|
tmpl = repo.ui.config('committemplate', ref)
|
2016-10-03 14:39:51 +03:00
|
|
|
if tmpl:
|
|
|
|
committext = cmdutil.buildcommittemplate(
|
2017-06-19 13:01:18 +03:00
|
|
|
repo, ctx, subs, extramsg, ref)
|
2016-10-03 14:39:51 +03:00
|
|
|
break
|
|
|
|
forms.pop()
|
|
|
|
else:
|
|
|
|
committext = cmdutil.buildcommittext(repo, ctx, subs, extramsg)
|
|
|
|
|
|
|
|
ui.status(committext)
|