py3: only pass unicode to json.dumps in writediffproperties
authorIan Moody <moz-ian@perix.co.uk>
Sat, 09 Mar 2019 01:53:53 +0000
changeset 41903 8fd19a7b4ed6
parent 41902 59bae59b7498
child 41904 634b56b54e7c
py3: only pass unicode to json.dumps in writediffproperties Differential Revision: https://phab.mercurial-scm.org/D6109
hgext/phabricator.py
--- a/hgext/phabricator.py	Sat Mar 09 01:30:44 2019 +0000
+++ b/hgext/phabricator.py	Sat Mar 09 01:53:53 2019 +0000
@@ -371,10 +371,10 @@
         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)
@@ -383,10 +383,11 @@
         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]),
             },
         }),
     }