Mercurial > hg-stable
changeset 39322:3a60416c4fd8
commitextras: no need to special case extras=[]
Differential Revision: https://phab.mercurial-scm.org/D4405
author | Valentin Gatien-Baron <vgatien-baron@janestreet.com> |
---|---|
date | Mon, 27 Aug 2018 16:03:00 -0400 |
parents | 1cb7c9777852 |
children | ce145f8eface |
files | hgext/commitextras.py |
diffstat | 1 files changed, 18 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/commitextras.py Mon Aug 27 16:01:55 2018 -0400 +++ b/hgext/commitextras.py Mon Aug 27 16:03:00 2018 -0400 @@ -49,25 +49,24 @@ class repoextra(repo.__class__): def commit(self, *innerpats, **inneropts): extras = opts.get(r'extra') - if extras: - for raw in extras: - if '=' not in raw: - msg = _("unable to parse '%s', should follow " - "KEY=VALUE format") - raise error.Abort(msg % raw) - k, v = raw.split('=', 1) - if not k: - msg = _("unable to parse '%s', keys can't be empty") - raise error.Abort(msg % raw) - if re.search('[^\w-]', k): - msg = _("keys can only contain ascii letters, digits," - " '_' and '-'") - raise error.Abort(msg) - if k in usedinternally: - msg = _("key '%s' is used internally, can't be set " - "manually") - raise error.Abort(msg % k) - inneropts[r'extra'][k] = v + for raw in extras: + if '=' not in raw: + msg = _("unable to parse '%s', should follow " + "KEY=VALUE format") + raise error.Abort(msg % raw) + k, v = raw.split('=', 1) + if not k: + msg = _("unable to parse '%s', keys can't be empty") + raise error.Abort(msg % raw) + if re.search('[^\w-]', k): + msg = _("keys can only contain ascii letters, digits," + " '_' and '-'") + raise error.Abort(msg) + if k in usedinternally: + msg = _("key '%s' is used internally, can't be set " + "manually") + raise error.Abort(msg % k) + inneropts[r'extra'][k] = v return super(repoextra, self).commit(*innerpats, **inneropts) repo.__class__ = repoextra return orig(ui, repo, *pats, **opts)