D7053: phabricator: switch to the creatediff endpoint
Kwan (Ian Moody)
phabricator at mercurial-scm.org
Thu Oct 10 21:53:10 UTC 2019
Kwan created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
This lets the extension submit binary files, as well as set branch info so that
it is exposed in the Phabricator interface.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D7053
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
@@ -799,11 +799,20 @@
"""create a Differential Diff"""
repo = ctx.repo()
repophid = getrepophid(repo)
- # Create a "Differential Diff" via "differential.createrawdiff" API
- params = {b'diff': getdiff(ctx, mdiff.diffopts(git=True, context=32767))}
+ # Create a "Differential Diff" via "differential.creatediff" API
+ pdiff = phabdiff(
+ sourceControlBaseRevision=b'%s' % ctx.p1().hex(),
+ branch=b'%s' % ctx.branch(),
+ )
+ modified, added, removed, _d, _u, _i, _c = ctx.p1().status(ctx)
+ # addadded will remove moved files from removed, so addremoved won't get
+ # them
+ addadded(pdiff, ctx, added, removed)
+ addmodified(pdiff, ctx, modified)
+ addremoved(pdiff, ctx, removed)
if repophid:
- params[b'repositoryPHID'] = repophid
- diff = callconduit(repo.ui, b'differential.createrawdiff', params)
+ pdiff.repositoryPHID = repophid
+ diff = callconduit(repo.ui, b'differential.creatediff', attr.asdict(pdiff))
if not diff:
raise error.Abort(_(b'cannot create diff for %s') % ctx)
return diff
@@ -811,8 +820,10 @@
def writediffproperties(ctx, diff):
"""write metadata to diff so patches could be applied losslessly"""
+ # creatediff returns with a diffid but query returns with an id
+ diffid = diff.get(b'diffid', diff.get(b'id'))
params = {
- b'diff_id': diff[b'id'],
+ b'diff_id': diffid,
b'name': b'hg:meta',
b'data': templatefilters.json(
{
@@ -827,7 +838,7 @@
callconduit(ctx.repo().ui, b'differential.setdiffproperty', params)
params = {
- b'diff_id': diff[b'id'],
+ b'diff_id': diffid,
b'name': b'local:commits',
b'data': templatefilters.json(
{
To: Kwan, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list