D6295: phabricator: use templatefilters.json instead of json.dumps in writediffproperties
Kwan (Ian Moody)
phabricator at mercurial-scm.org
Mon Apr 22 15:45:24 UTC 2019
Kwan created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
Makes the code simpler and more readable.
This would have been the better option for https://phab.mercurial-scm.org/rHG8fd19a7b4ed69583d90d0f9af98c791d111d1367 but I wasn't aware of
it at the time.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D6295
AFFECTED FILES
hgext/phabricator.py
CHANGE DETAILS
diff --git a/hgext/phabricator.py b/hgext/phabricator.py
--- a/hgext/phabricator.py
+++ b/hgext/phabricator.py
@@ -65,6 +65,7 @@
scmutil,
smartset,
tags,
+ templatefilters,
templateutil,
url as urlmod,
util,
@@ -380,24 +381,23 @@
params = {
b'diff_id': diff[b'id'],
b'name': b'hg:meta',
- b'data': json.dumps({
- 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()),
+ b'data': templatefilters.json({
+ b'user': ctx.user(),
+ b'date': b'%d %d' % ctx.date(),
+ b'node': ctx.hex(),
+ b'parent': 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({
- 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]),
+ b'data': templatefilters.json({
+ ctx.hex(): {
+ b'author': stringutil.person(ctx.user()),
+ b'authorEmail': stringutil.email(ctx.user()),
+ b'time': b'%d' % ctx.date()[0],
},
}),
}
To: Kwan, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list