sapling/hgext/debugcommitmessage.py
Kostia Balytskyi e75b9fc1b1 fb-hgext: move most of hgext3rd and related tests to core
Summary:
This commit moves most of the stuff in hgext3rd and related tests to
hg-crew/hgext and hg-crew/test respectively.

The things that are not moved are the ones which require some more complex
imports.


Depends on D6675309

Test Plan: - tests are failing at this commit, fixes are in the following commits

Reviewers: #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D6675329
2018-01-09 03:03:59 -08:00

46 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:
ref = '.'.join(forms)
tmpl = repo.ui.config('committemplate', ref)
if tmpl:
committext = cmdutil.buildcommittemplate(
repo, ctx, subs, extramsg, ref)
break
forms.pop()
else:
committext = cmdutil.buildcommittext(repo, ctx, subs, extramsg)
ui.status(committext)