Read about our upcoming Code of Conduct on this issue

This instance will be upgraded to Heptapod 0.28.0 on 2022-01-18 at 14:00 UTC+1 (a few minutes of down time)

Commit bf79c1cb authored by Martin von Zweigbergk's avatar Martin von Zweigbergk
Browse files

errors: use detailed error for invalid commit-extras argument

Differential Revision: https://phab.mercurial-scm.org/D11831
parent 35f1ecd84bd0
Pipeline #29742 failed with stages
in 40 minutes and 51 seconds
......@@ -65,23 +65,23 @@ def _commit(orig, ui, repo, *pats, **opts):
b"unable to parse '%s', should follow "
b"KEY=VALUE format"
)
raise error.Abort(msg % raw)
raise error.InputError(msg % raw)
k, v = raw.split(b'=', 1)
if not k:
msg = _(b"unable to parse '%s', keys can't be empty")
raise error.Abort(msg % raw)
raise error.InputError(msg % raw)
if re.search(br'[^\w-]', k):
msg = _(
b"keys can only contain ascii letters, digits,"
b" '_' and '-'"
)
raise error.Abort(msg)
raise error.InputError(msg)
if k in usedinternally:
msg = _(
b"key '%s' is used internally, can't be set "
b"manually"
)
raise error.Abort(msg % k)
raise error.InputError(msg % k)
inneropts['extra'][k] = v
return super(repoextra, self).commit(*innerpats, **inneropts)
......
......@@ -134,13 +134,13 @@ Using the advanced --extra flag
$ hg add quux
$ hg commit -m "adding internal used extras" --extra amend_source=hash
abort: key 'amend_source' is used internally, can't be set manually
[255]
[10]
$ hg commit -m "special chars in extra" --extra id@phab=214
abort: keys can only contain ascii letters, digits, '_' and '-'
[255]
[10]
$ hg commit -m "empty key" --extra =value
abort: unable to parse '=value', keys can't be empty
[255]
[10]
$ hg commit -m "adding extras" --extra sourcehash=foo --extra oldhash=bar
$ hg log -r . -T '{extras % "{extra}\n"}'
branch=default
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment