From patchwork Thu Oct 10 21:52:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D7042: phabricator: add the phabhunk data structure From: phabricator X-Patchwork-Id: 42198 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Thu, 10 Oct 2019 21:52:08 +0000 Kwan created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY These store the actual diff data (for UTF-8 text files anyway) and are equivalent to hunks in a patch file. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D7042 AFFECTED FILES hgext/phabricator.py CHANGE DETAILS To: Kwan, #hg-reviewers Cc: mercurial-devel diff --git a/hgext/phabricator.py b/hgext/phabricator.py --- a/hgext/phabricator.py +++ b/hgext/phabricator.py @@ -50,6 +50,7 @@ from mercurial.node import bin, nullid from mercurial.i18n import _ from mercurial.pycompat import getattr +from mercurial.thirdparty import attr from mercurial import ( cmdutil, context, @@ -465,6 +466,21 @@ BINARY = 3 +@attr.s +class phabhunk(dict): + """Represents a Differential hunk, which is owned by a Differential change + """ + + oldOffset = attr.ib(default=0) + oldLength = attr.ib(default=0) + newOffset = attr.ib(default=0) + newLength = attr.ib(default=0) + corpus = attr.ib(default='') + # These get added to the phabchange's equivalents + addLines = attr.ib(default=0) + delLines = attr.ib(default=0) + + def creatediff(ctx): """create a Differential Diff""" repo = ctx.repo()