sapling/eden/scm/edenscm/hgext/debugcommitmessage.py
Adam Simpkins ab3a7cb21f Move fb-mercurial sources into an eden/scm subdirectory.
Summary:
In preparation for merging fb-mercurial sources to the Eden repository,
move everything from the top-level directory into an `eden/scm`
subdirectory.
2019-11-13 16:04:48 -08:00

46 lines
1.2 KiB
Python

# Copyright (c) Facebook, Inc. and its affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from edenscm.mercurial import cmdutil, context, error, registrar
from edenscm.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)
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, extramsg, ref)
break
forms.pop()
else:
committext = cmdutil.buildcommittext(repo, ctx, extramsg)
ui.status(committext)