diff --git a/hgext/phabricator.py b/hgext/phabricator.py --- a/hgext/phabricator.py +++ b/hgext/phabricator.py @@ -718,11 +718,12 @@ ) -def maketext(pchange, basectx, ctx, fname): +def maketext(pchange, basectx, ctx, fname, options={}): """populate the phabchange for a text file""" repo = ctx.repo() fmatcher = match.exact([fname]) - diffopts = mdiff.diffopts(git=True, context=32767) + context = options.get(b'context', 32767) + diffopts = mdiff.diffopts(git=True, context=context) _pfctx, _fctx, header, fhunks = next( patch.diffhunks(repo, basectx.p1(), ctx, fmatcher, opts=diffopts) ) @@ -884,7 +885,7 @@ pdiff.addchange(pchange) -def addmodified(pdiff, basectx, ctx, modified): +def addmodified(pdiff, basectx, ctx, modified, diffoptions): """add modified files to the phabdiff""" for fname in modified: fctx = ctx[fname] @@ -905,12 +906,12 @@ makebinary(pchange, fctx) addoldbinary(pchange, oldfctx, fctx) else: - maketext(pchange, basectx, ctx, fname) + maketext(pchange, basectx, ctx, fname, diffoptions) pdiff.addchange(pchange) -def addadded(pdiff, basectx, ctx, added, removed): +def addadded(pdiff, basectx, ctx, added, removed, diffoptions): """add file adds to the phabdiff, both new files and copies/moves""" # Keep track of files that've been recorded as moved/copied, so if there are # additional copies we can mark them (moves get removed from removed) @@ -983,7 +984,7 @@ if renamed: addoldbinary(pchange, oldfctx, fctx) else: - maketext(pchange, basectx, ctx, fname) + maketext(pchange, basectx, ctx, fname, diffoptions) pdiff.addchange(pchange) @@ -993,7 +994,7 @@ pdiff.addchange(movedchange) -def creatediff(basectx, ctx): +def creatediff(basectx, ctx, diffoptions={}): """create a Differential Diff""" repo = ctx.repo() repophid = getrepophid(repo) @@ -1005,8 +1006,8 @@ modified, added, removed, _d, _u, _i, _c = basectx.p1().status(ctx) # addadded will remove moved files from removed, so addremoved won't get # them - addadded(pdiff, basectx, ctx, added, removed) - addmodified(pdiff, basectx, ctx, modified) + addadded(pdiff, basectx, ctx, added, removed, diffoptions) + addmodified(pdiff, basectx, ctx, modified, diffoptions) addremoved(pdiff, basectx, ctx, removed) if repophid: pdiff.repositoryPHID = repophid @@ -1078,6 +1079,7 @@ olddiff=None, actions=None, comment=None, + diffoptions={}, ): """create or update a Differential Revision @@ -1115,7 +1117,7 @@ transactions = [] if neednewdiff: - diff = creatediff(basectx, ctx) + diff = creatediff(basectx, ctx, diffoptions) transactions.append({b'type': b'update', b'value': diff[b'phid']}) if comment: transactions.append({b'type': b'comment', b'value': comment}) @@ -1387,6 +1389,7 @@ if phids: actions.append({b'type': b'reviewers.add', b'value': phids}) + diffoptions = {} drevids = [] # [int] diffmap = {} # {newnode: diff} @@ -1419,6 +1422,7 @@ olddiff, actions, opts.get(b'comment'), + diffoptions, ) if fold: