Patchwork D8332: py3: require values in changelog extras to be bytes

login
register
mail settings
Submitter phabricator
Date March 26, 2020, 2:19 a.m.
Message ID <differential-rev-PHID-DREV-5iqdfv6etqetaq6eqint-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/45895/
State Superseded
Headers show

Comments

phabricator - March 26, 2020, 2:19 a.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I don't know what happened here because b436059c1cca <https://phab.mercurial-scm.org/rHGb436059c1cca85ec327889a8fba17837e5c7b8e6> (py3: use
  pycompat.bytestr() on extra values because it can be int, 2019-02-05)
  came about b44a47214122 <https://phab.mercurial-scm.org/rHGb44a4721412228aec4fde226bef594f4691ea61f> (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).

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8332

AFFECTED FILES
  mercurial/changelog.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -82,10 +82,7 @@ 
 
 def encodeextra(d):
     # keys must be sorted to produce a deterministic changelog entry
-    items = [
-        _string_escape(b'%s:%s' % (k, pycompat.bytestr(d[k])))
-        for k in sorted(d)
-    ]
+    items = [_string_escape(b'%s:%s' % (k, d[k])) for k in sorted(d)]
     return b"\0".join(items)