changeset 41903:8fd19a7b4ed6

py3: only pass unicode to json.dumps in writediffproperties Differential Revision: https://phab.mercurial-scm.org/D6109
author Ian Moody <moz-ian@perix.co.uk>
date Sat, 09 Mar 2019 01:53:53 +0000
parents 59bae59b7498
children 634b56b54e7c
files hgext/phabricator.py
diffstat 1 files changed, 9 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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]),
             },
         }),
     }