Mercurial > hg
comparison mercurial/changelog.py @ 44604:2141427533d2 stable
py3: require values in changelog extras to be bytes
I don't know what happened here because b436059c1cca (py3: use
pycompat.bytestr() on extra values because it can be int, 2019-02-05)
came about b44a47214122 (py3: use string for "close" value in commit
extras, 2018-02-11). Whatever happened, we shouldn't need to convert
the values to bytes now. It's better to not convert because that might
cover up bugs where someone sets a unicode value in the extras and
that works until the unicode value happens to contain non-ascii (at
which point it will fail because `bytestr()` expects its argument to
be ascii if it's unicode).
Differential Revision: https://phab.mercurial-scm.org/D8332
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 25 Mar 2020 18:50:40 -0700 |
parents | 7f67f53492f7 |
children | e147748f750b |
comparison
equal
deleted
inserted
replaced
44603:bda050bc9987 | 44604:2141427533d2 |
---|---|
80 return extra | 80 return extra |
81 | 81 |
82 | 82 |
83 def encodeextra(d): | 83 def encodeextra(d): |
84 # keys must be sorted to produce a deterministic changelog entry | 84 # keys must be sorted to produce a deterministic changelog entry |
85 items = [ | 85 items = [_string_escape(b'%s:%s' % (k, d[k])) for k in sorted(d)] |
86 _string_escape(b'%s:%s' % (k, pycompat.bytestr(d[k]))) | |
87 for k in sorted(d) | |
88 ] | |
89 return b"\0".join(items) | 86 return b"\0".join(items) |
90 | 87 |
91 | 88 |
92 def stripdesc(desc): | 89 def stripdesc(desc): |
93 """strip trailing whitespace and leading and trailing empty lines""" | 90 """strip trailing whitespace and leading and trailing empty lines""" |