##// END OF EJS Templates
commitextras: make sure keys contains ascii letters, numbers, '_' and '-' only
Pulkit Goyal -
r33603:27fbca75 stable
parent child Browse files
Show More
@@ -9,6 +9,8 b''
9
9
10 from __future__ import absolute_import
10 from __future__ import absolute_import
11
11
12 import re
13
12 from mercurial.i18n import _
14 from mercurial.i18n import _
13 from mercurial import (
15 from mercurial import (
14 commands,
16 commands,
@@ -52,6 +54,10 b' def _commit(orig, ui, repo, *pats, **opt'
52 "KEY=VALUE format")
54 "KEY=VALUE format")
53 raise error.Abort(msg % raw)
55 raise error.Abort(msg % raw)
54 k, v = raw.split('=', 1)
56 k, v = raw.split('=', 1)
57 if re.search('[^\w-]', k):
58 msg = _("keys can only contain ascii letters, digits,"
59 " '_' and '-'")
60 raise error.Abort(msg)
55 if k in usedinternally:
61 if k in usedinternally:
56 msg = _("key '%s' is used internally, can't be set "
62 msg = _("key '%s' is used internally, can't be set "
57 "manually")
63 "manually")
@@ -135,6 +135,9 b' Using the advanced --extra flag'
135 $ hg commit -m "adding internal used extras" --extra amend_source=hash
135 $ hg commit -m "adding internal used extras" --extra amend_source=hash
136 abort: key 'amend_source' is used internally, can't be set manually
136 abort: key 'amend_source' is used internally, can't be set manually
137 [255]
137 [255]
138 $ hg commit -m "special chars in extra" --extra id@phab=214
139 abort: keys can only contain ascii letters, digits, '_' and '-'
140 [255]
138 $ hg commit -m "adding extras" --extra sourcehash=foo --extra oldhash=bar
141 $ hg commit -m "adding extras" --extra sourcehash=foo --extra oldhash=bar
139 $ hg log -r . -T '{extras % "{extra}\n"}'
142 $ hg log -r . -T '{extras % "{extra}\n"}'
140 branch=default
143 branch=default
General Comments 0
You need to be logged in to leave comments. Login now