Details
Details
- Reviewers
yuja - Group Reviewers
hg-reviewers - Commits
- rHG901a18b03e00: py3: handle keyword arguments in hgext/commitextras.py
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
( )
yuja |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
options = entry[1] | options = entry[1] | ||||
options.append(('', 'extra', [], | options.append(('', 'extra', [], | ||||
_('set a changeset\'s extra values'), _("KEY=VALUE"))) | _('set a changeset\'s extra values'), _("KEY=VALUE"))) | ||||
def _commit(orig, ui, repo, *pats, **opts): | def _commit(orig, ui, repo, *pats, **opts): | ||||
origcommit = repo.commit | origcommit = repo.commit | ||||
try: | try: | ||||
def _wrappedcommit(*innerpats, **inneropts): | def _wrappedcommit(*innerpats, **inneropts): | ||||
extras = opts.get('extra') | extras = opts.get(r'extra') | ||||
if extras: | if extras: | ||||
for raw in extras: | for raw in extras: | ||||
if '=' not in raw: | if '=' not in raw: | ||||
msg = _("unable to parse '%s', should follow " | msg = _("unable to parse '%s', should follow " | ||||
"KEY=VALUE format") | "KEY=VALUE format") | ||||
raise error.Abort(msg % raw) | raise error.Abort(msg % raw) | ||||
k, v = raw.split('=', 1) | k, v = raw.split('=', 1) | ||||
if not k: | if not k: | ||||
msg = _("unable to parse '%s', keys can't be empty") | msg = _("unable to parse '%s', keys can't be empty") | ||||
raise error.Abort(msg % raw) | raise error.Abort(msg % raw) | ||||
if re.search('[^\w-]', k): | if re.search('[^\w-]', k): | ||||
msg = _("keys can only contain ascii letters, digits," | msg = _("keys can only contain ascii letters, digits," | ||||
" '_' and '-'") | " '_' and '-'") | ||||
raise error.Abort(msg) | raise error.Abort(msg) | ||||
if k in usedinternally: | if k in usedinternally: | ||||
msg = _("key '%s' is used internally, can't be set " | msg = _("key '%s' is used internally, can't be set " | ||||
"manually") | "manually") | ||||
raise error.Abort(msg % k) | raise error.Abort(msg % k) | ||||
inneropts['extra'][k] = v | inneropts[r'extra'][k] = v | ||||
return origcommit(*innerpats, **inneropts) | return origcommit(*innerpats, **inneropts) | ||||
# This __dict__ logic is needed because the normal | # This __dict__ logic is needed because the normal | ||||
# extension.wrapfunction doesn't seem to work. | # extension.wrapfunction doesn't seem to work. | ||||
repo.__dict__['commit'] = _wrappedcommit | repo.__dict__['commit'] = _wrappedcommit | ||||
return orig(ui, repo, *pats, **opts) | return orig(ui, repo, *pats, **opts) | ||||
finally: | finally: | ||||
del repo.__dict__['commit'] | del repo.__dict__['commit'] |