Mercurial > public > mercurial-scm > hg
comparison hgext/phabricator.py @ 43183:73d4bc60e389
phabricator: add the phabhunk data structure
These store the actual diff data (for UTF-8 text files anyway) and are
equivalent to hunks in a patch file.
Differential Revision: https://phab.mercurial-scm.org/D7042
author | Ian Moody <moz-ian@perix.co.uk> |
---|---|
date | Sun, 06 Oct 2019 13:55:04 +0100 |
parents | a66e2844b0c6 |
children | 99ee4afd352f |
comparison
equal
deleted
inserted
replaced
43182:a66e2844b0c6 | 43183:73d4bc60e389 |
---|---|
48 import re | 48 import re |
49 | 49 |
50 from mercurial.node import bin, nullid | 50 from mercurial.node import bin, nullid |
51 from mercurial.i18n import _ | 51 from mercurial.i18n import _ |
52 from mercurial.pycompat import getattr | 52 from mercurial.pycompat import getattr |
53 from mercurial.thirdparty import attr | |
53 from mercurial import ( | 54 from mercurial import ( |
54 cmdutil, | 55 cmdutil, |
55 context, | 56 context, |
56 encoding, | 57 encoding, |
57 error, | 58 error, |
461 | 462 |
462 class DiffFileType(object): | 463 class DiffFileType(object): |
463 TEXT = 1 | 464 TEXT = 1 |
464 IMAGE = 2 | 465 IMAGE = 2 |
465 BINARY = 3 | 466 BINARY = 3 |
467 | |
468 | |
469 @attr.s | |
470 class phabhunk(dict): | |
471 """Represents a Differential hunk, which is owned by a Differential change | |
472 """ | |
473 | |
474 oldOffset = attr.ib(default=0) # camelcase-required | |
475 oldLength = attr.ib(default=0) # camelcase-required | |
476 newOffset = attr.ib(default=0) # camelcase-required | |
477 newLength = attr.ib(default=0) # camelcase-required | |
478 corpus = attr.ib(default='') | |
479 # These get added to the phabchange's equivalents | |
480 addLines = attr.ib(default=0) # camelcase-required | |
481 delLines = attr.ib(default=0) # camelcase-required | |
466 | 482 |
467 | 483 |
468 def creatediff(ctx): | 484 def creatediff(ctx): |
469 """create a Differential Diff""" | 485 """create a Differential Diff""" |
470 repo = ctx.repo() | 486 repo = ctx.repo() |