# HG changeset patch # User Valentin Gatien-Baron # Date 1535400180 14400 # Node ID 3a60416c4fd8eaabe7ea5a52d6391b0aadb79cfc # Parent 1cb7c97778524d6f3c3c536836a6192c10d1d88d commitextras: no need to special case extras=[] Differential Revision: https://phab.mercurial-scm.org/D4405 diff -r 1cb7c9777852 -r 3a60416c4fd8 hgext/commitextras.py --- 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)