2015-04-28 06:20:48 +03:00
|
|
|
# commitextras.py
|
|
|
|
#
|
|
|
|
# Copyright 2013 Facebook, Inc.
|
|
|
|
#
|
|
|
|
# This software may be used and distributed according to the terms of the
|
|
|
|
# GNU General Public License version 2 or any later version.
|
|
|
|
|
|
|
|
from mercurial.i18n import _
|
2016-11-25 03:23:21 +03:00
|
|
|
from mercurial import (
|
|
|
|
commands,
|
|
|
|
extensions,
|
2017-05-22 23:38:37 +03:00
|
|
|
registrar,
|
2016-11-25 03:23:21 +03:00
|
|
|
)
|
2015-04-28 06:20:48 +03:00
|
|
|
|
|
|
|
cmdtable = {}
|
2017-05-22 23:38:37 +03:00
|
|
|
command = registrar.command(cmdtable)
|
2016-11-29 16:24:07 +03:00
|
|
|
testedwith = 'ships-with-fb-hgext'
|
2015-04-28 06:20:48 +03:00
|
|
|
|
|
|
|
def extsetup(ui):
|
|
|
|
entry = extensions.wrapcommand(commands.table, 'commit', _commit)
|
|
|
|
options = entry[1]
|
|
|
|
options.append(('', 'extra', [],
|
2016-09-21 17:45:25 +03:00
|
|
|
_('set a changeset\'s extra values'), _("KEY=VALUE")))
|
2015-04-28 06:20:48 +03:00
|
|
|
|
|
|
|
def _commit(orig, ui, repo, *pats, **opts):
|
|
|
|
origcommit = repo.commit
|
|
|
|
try:
|
|
|
|
def _wrappedcommit(*innerpats, **inneropts):
|
|
|
|
extras = opts.get('extra')
|
|
|
|
if extras:
|
|
|
|
for raw in extras:
|
|
|
|
k, v = raw.split('=', 1)
|
|
|
|
inneropts['extra'][k] = v
|
|
|
|
return origcommit(*innerpats, **inneropts)
|
|
|
|
|
|
|
|
# This __dict__ logic is needed because the normal
|
|
|
|
# extension.wrapfunction doesn't seem to work.
|
|
|
|
repo.__dict__['commit'] = _wrappedcommit
|
|
|
|
return orig(ui, repo, *pats, **opts)
|
|
|
|
finally:
|
|
|
|
del repo.__dict__['commit']
|