diff --git a/hgext/commitextras.py b/hgext/commitextras.py --- a/hgext/commitextras.py +++ b/hgext/commitextras.py @@ -54,6 +54,9 @@ def _commit(orig, ui, repo, *pats, **opt "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 '-'") diff --git a/tests/test-commit.t b/tests/test-commit.t --- a/tests/test-commit.t +++ b/tests/test-commit.t @@ -138,6 +138,9 @@ Using the advanced --extra flag $ hg commit -m "special chars in extra" --extra id@phab=214 abort: keys can only contain ascii letters, digits, '_' and '-' [255] + $ hg commit -m "empty key" --extra =value + abort: unable to parse '=value', keys can't be empty + [255] $ hg commit -m "adding extras" --extra sourcehash=foo --extra oldhash=bar $ hg log -r . -T '{extras % "{extra}\n"}' branch=default