Patchwork D6109: py3: only pass unicode to json.dumps in writediffproperties

login
register
mail settings
Submitter phabricator
Date March 10, 2019, 1:50 a.m.
Message ID <35721f883686daf62e5a62383b0469a0@localhost.localdomain>
Download mbox | patch
Permalink /patch/39175/
State Not Applicable
Headers show

Comments

phabricator - March 10, 2019, 1:50 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG8fd19a7b4ed6: py3: only pass unicode to json.dumps in writediffproperties (authored by Kwan, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D6109?vs=14422&id=14434#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6109?vs=14422&id=14434

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

AFFECTED FILES
  hgext/phabricator.py

CHANGE DETAILS




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

Patch

diff --git a/hgext/phabricator.py b/hgext/phabricator.py
--- a/hgext/phabricator.py
+++ b/hgext/phabricator.py
@@ -371,22 +371,23 @@ 
         b'diff_id': diff[b'id'],
         b'name': b'hg:meta',
         b'data': json.dumps({
-            b'user': ctx.user(),
-            b'date': b'%d %d' % ctx.date(),
-            b'node': ctx.hex(),
-            b'parent': ctx.p1().hex(),
+            u'user': encoding.unifromlocal(ctx.user()),
+            u'date': u'{:.0f} {}'.format(*ctx.date()),
+            u'node': encoding.unifromlocal(ctx.hex()),
+            u'parent': encoding.unifromlocal(ctx.p1().hex()),
         }),
     }
     callconduit(ctx.repo(), b'differential.setdiffproperty', params)
 
     params = {
         b'diff_id': diff[b'id'],
         b'name': b'local:commits',
         b'data': json.dumps({
-            ctx.hex(): {
-                b'author': stringutil.person(ctx.user()),
-                b'authorEmail': stringutil.email(ctx.user()),
-                b'time': ctx.date()[0],
+            encoding.unifromlocal(ctx.hex()): {
+                u'author': encoding.unifromlocal(stringutil.person(ctx.user())),
+                u'authorEmail': encoding.unifromlocal(
+                    stringutil.email(ctx.user())),
+                u'time': u'{:.0f}'.format(ctx.date()[0]),
             },
         }),
     }