Patchwork D7053: phabricator: switch to the creatediff endpoint

login
register
mail settings
Submitter phabricator
Date Oct. 16, 2019, 8:51 p.m.
Message ID <0792c484781e5c64a61dad1ed42e5f70@localhost.localdomain>
Download mbox | patch
Permalink /patch/42424/
State Not Applicable
Headers show

Comments

phabricator - Oct. 16, 2019, 8:51 p.m.
Closed by commit rHGd5fabfe54ec6: phabricator: switch to the creatediff endpoint (authored by Kwan).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7053?vs=17103&id=17258

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7053/new/

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

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
@@ -800,11 +800,24 @@ 
     """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',
+        pycompat.byteskwargs(attr.asdict(pdiff)),
+    )
     if not diff:
         raise error.Abort(_(b'cannot create diff for %s') % ctx)
     return diff
@@ -812,8 +825,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(
             {
@@ -828,7 +843,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(
             {