sapling/tests/hggit/commitextra.py
Jun Wu fd071d2076 cmdutil: change logmessage to take a repo
Summary:
Change `cmdutil.logmessage` to take a `repo` instead of `ui`. This makes the
next change easier.

Reviewed By: xavierd

Differential Revision: D17168990

fbshipit-source-id: 47c1707e5a9dbf06d07452b4c400903453992379
2019-09-04 17:06:35 -07:00

39 lines
947 B
Python

"""test helper extension to create commits with multiple extra fields"""
from edenscm.mercurial import cmdutil, commands, scmutil
cmdtable = {}
try:
from edenscm.mercurial import registrar
command = registrar.command(cmdtable)
except (ImportError, AttributeError):
command = cmdutil.command(cmdtable)
testedwith = "internal"
@command(
"commitextra",
[("", "field", [], "extra data to store", "FIELD=VALUE")]
+ commands.commitopts
+ commands.commitopts2,
"commitextra",
)
def commitextra(ui, repo, *pats, **opts):
"""make a commit with extra fields"""
fields = opts.get("field")
extras = {}
for field in fields:
k, v = field.split("=", 1)
extras[k] = v
message = cmdutil.logmessage(repo, opts)
repo.commit(
message,
opts.get("user"),
opts.get("date"),
match=scmutil.match(repo[None], pats, opts),
extra=extras,
)
return 0