798 |
798 |
799 def creatediff(ctx): |
799 def creatediff(ctx): |
800 """create a Differential Diff""" |
800 """create a Differential Diff""" |
801 repo = ctx.repo() |
801 repo = ctx.repo() |
802 repophid = getrepophid(repo) |
802 repophid = getrepophid(repo) |
803 # Create a "Differential Diff" via "differential.createrawdiff" API |
803 # Create a "Differential Diff" via "differential.creatediff" API |
804 params = {b'diff': getdiff(ctx, mdiff.diffopts(git=True, context=32767))} |
804 pdiff = phabdiff( |
|
805 sourceControlBaseRevision=b'%s' % ctx.p1().hex(), |
|
806 branch=b'%s' % ctx.branch(), |
|
807 ) |
|
808 modified, added, removed, _d, _u, _i, _c = ctx.p1().status(ctx) |
|
809 # addadded will remove moved files from removed, so addremoved won't get |
|
810 # them |
|
811 addadded(pdiff, ctx, added, removed) |
|
812 addmodified(pdiff, ctx, modified) |
|
813 addremoved(pdiff, ctx, removed) |
805 if repophid: |
814 if repophid: |
806 params[b'repositoryPHID'] = repophid |
815 pdiff.repositoryPHID = repophid |
807 diff = callconduit(repo.ui, b'differential.createrawdiff', params) |
816 diff = callconduit( |
|
817 repo.ui, |
|
818 b'differential.creatediff', |
|
819 pycompat.byteskwargs(attr.asdict(pdiff)), |
|
820 ) |
808 if not diff: |
821 if not diff: |
809 raise error.Abort(_(b'cannot create diff for %s') % ctx) |
822 raise error.Abort(_(b'cannot create diff for %s') % ctx) |
810 return diff |
823 return diff |
811 |
824 |
812 |
825 |
813 def writediffproperties(ctx, diff): |
826 def writediffproperties(ctx, diff): |
814 """write metadata to diff so patches could be applied losslessly""" |
827 """write metadata to diff so patches could be applied losslessly""" |
|
828 # creatediff returns with a diffid but query returns with an id |
|
829 diffid = diff.get(b'diffid', diff.get(b'id')) |
815 params = { |
830 params = { |
816 b'diff_id': diff[b'id'], |
831 b'diff_id': diffid, |
817 b'name': b'hg:meta', |
832 b'name': b'hg:meta', |
818 b'data': templatefilters.json( |
833 b'data': templatefilters.json( |
819 { |
834 { |
820 b'user': ctx.user(), |
835 b'user': ctx.user(), |
821 b'date': b'%d %d' % ctx.date(), |
836 b'date': b'%d %d' % ctx.date(), |
826 ), |
841 ), |
827 } |
842 } |
828 callconduit(ctx.repo().ui, b'differential.setdiffproperty', params) |
843 callconduit(ctx.repo().ui, b'differential.setdiffproperty', params) |
829 |
844 |
830 params = { |
845 params = { |
831 b'diff_id': diff[b'id'], |
846 b'diff_id': diffid, |
832 b'name': b'local:commits', |
847 b'name': b'local:commits', |
833 b'data': templatefilters.json( |
848 b'data': templatefilters.json( |
834 { |
849 { |
835 ctx.hex(): { |
850 ctx.hex(): { |
836 b'author': stringutil.person(ctx.user()), |
851 b'author': stringutil.person(ctx.user()), |