D7045: phabricator: add the maketext function
Kwan (Ian Moody)
phabricator at mercurial-scm.org
Fri Oct 11 21:56:55 EDT 2019
Closed by commit rHGf742fabad507: phabricator: add the maketext function (authored by Kwan).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D7045?vs=17076&id=17093
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D7045/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D7045
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
@@ -58,6 +58,7 @@
error,
exthelper,
httpconnection as httpconnectionmod,
+ match,
mdiff,
obsutil,
parser,
@@ -548,6 +549,36 @@
self.changes[change.currentPath] = change
+def maketext(pchange, ctx, fname):
+ """populate the phabchange for a text file"""
+ repo = ctx.repo()
+ fmatcher = match.exact([fname])
+ diffopts = mdiff.diffopts(git=True, context=32767)
+ _pfctx, _fctx, header, fhunks = next(
+ patch.diffhunks(repo, ctx.p1(), ctx, fmatcher, opts=diffopts)
+ )
+
+ for fhunk in fhunks:
+ (oldOffset, oldLength, newOffset, newLength), lines = fhunk
+ corpus = b''.join(lines[1:])
+ shunk = list(header)
+ shunk.extend(lines)
+ _mf, _mt, addLines, delLines, _hb = patch.diffstatsum(
+ patch.diffstatdata(util.iterlines(shunk))
+ )
+ pchange.addhunk(
+ phabhunk(
+ oldOffset,
+ oldLength,
+ newOffset,
+ newLength,
+ corpus,
+ addLines,
+ delLines,
+ )
+ )
+
+
def creatediff(ctx):
"""create a Differential Diff"""
repo = ctx.repo()
To: Kwan, #hg-reviewers, indygreg
Cc: indygreg, mercurial-devel
More information about the Mercurial-devel
mailing list