sapling/hgext3rd/debugcommitmessage.py
Durham Goode e34660b057 commands: update to use registrar instead of cmdutil
Summary: Upstream has deprecated cmdutil.commands() in favor of registrar.commands()

Test Plan: Ran the tests

Reviewers: #mercurial, quark

Reviewed By: quark

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5106486

Signature: t1:5106486:1495485074:0e20f00622cc651e8c9dda837f84dd84cc51099e
2017-05-22 13:38:37 -07:00

45 lines
1.1 KiB
Python

from mercurial import (
cmdutil,
context,
error,
registrar,
)
from mercurial.i18n import _
cmdtable = {}
command = registrar.command(cmdtable)
@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:
tmpl = repo.ui.config('committemplate', '.'.join(forms))
if tmpl:
committext = cmdutil.buildcommittemplate(
repo, ctx, subs, extramsg, tmpl)
break
forms.pop()
else:
committext = cmdutil.buildcommittext(repo, ctx, subs, extramsg)
ui.status(committext)