544 |
545 |
545 def addchange(self, change): |
546 def addchange(self, change): |
546 if not isinstance(change, phabchange): |
547 if not isinstance(change, phabchange): |
547 raise error.Abort(b'phabdiff.addchange only takes phabchanges') |
548 raise error.Abort(b'phabdiff.addchange only takes phabchanges') |
548 self.changes[change.currentPath] = change |
549 self.changes[change.currentPath] = change |
|
550 |
|
551 |
|
552 def maketext(pchange, ctx, fname): |
|
553 """populate the phabchange for a text file""" |
|
554 repo = ctx.repo() |
|
555 fmatcher = match.exact([fname]) |
|
556 diffopts = mdiff.diffopts(git=True, context=32767) |
|
557 _pfctx, _fctx, header, fhunks = next( |
|
558 patch.diffhunks(repo, ctx.p1(), ctx, fmatcher, opts=diffopts) |
|
559 ) |
|
560 |
|
561 for fhunk in fhunks: |
|
562 (oldOffset, oldLength, newOffset, newLength), lines = fhunk |
|
563 corpus = b''.join(lines[1:]) |
|
564 shunk = list(header) |
|
565 shunk.extend(lines) |
|
566 _mf, _mt, addLines, delLines, _hb = patch.diffstatsum( |
|
567 patch.diffstatdata(util.iterlines(shunk)) |
|
568 ) |
|
569 pchange.addhunk( |
|
570 phabhunk( |
|
571 oldOffset, |
|
572 oldLength, |
|
573 newOffset, |
|
574 newLength, |
|
575 corpus, |
|
576 addLines, |
|
577 delLines, |
|
578 ) |
|
579 ) |
549 |
580 |
550 |
581 |
551 def creatediff(ctx): |
582 def creatediff(ctx): |
552 """create a Differential Diff""" |
583 """create a Differential Diff""" |
553 repo = ctx.repo() |
584 repo = ctx.repo() |