Mercurial > public > mercurial-scm > hg
comparison hgext/phabricator.py @ 43259:162b81e65e60
phabricator: convert phabhunk and phabchange keys to bytes when finalising
I thought I had included this code already but I'd missed it out. One of the
disadvantages of attrs is that all the keys are unicode strings on py3, but we
need them to be byte strings.
Differential Revision: https://phab.mercurial-scm.org/D7066
author | Ian Moody <moz-ian@perix.co.uk> |
---|---|
date | Sat, 12 Oct 2019 14:41:59 +0100 |
parents | d5d1edf66091 |
children | f5aa4a53acd1 |
comparison
equal
deleted
inserted
replaced
43258:d5d1edf66091 | 43259:162b81e65e60 |
---|---|
516 self.newProperties[b'unix:filemode'] = value | 516 self.newProperties[b'unix:filemode'] = value |
517 | 517 |
518 def addhunk(self, hunk): | 518 def addhunk(self, hunk): |
519 if not isinstance(hunk, phabhunk): | 519 if not isinstance(hunk, phabhunk): |
520 raise error.Abort(b'phabchange.addhunk only takes phabhunks') | 520 raise error.Abort(b'phabchange.addhunk only takes phabhunks') |
521 self.hunks.append(hunk) | 521 self.hunks.append(pycompat.byteskwargs(attr.asdict(hunk))) |
522 # It's useful to include these stats since the Phab web UI shows them, | 522 # It's useful to include these stats since the Phab web UI shows them, |
523 # and uses them to estimate how large a change a Revision is. Also used | 523 # and uses them to estimate how large a change a Revision is. Also used |
524 # in email subjects for the [+++--] bit. | 524 # in email subjects for the [+++--] bit. |
525 self.addLines += hunk.addLines | 525 self.addLines += hunk.addLines |
526 self.delLines += hunk.delLines | 526 self.delLines += hunk.delLines |
547 repositoryPHID = attr.ib(default=None) # camelcase-required | 547 repositoryPHID = attr.ib(default=None) # camelcase-required |
548 | 548 |
549 def addchange(self, change): | 549 def addchange(self, change): |
550 if not isinstance(change, phabchange): | 550 if not isinstance(change, phabchange): |
551 raise error.Abort(b'phabdiff.addchange only takes phabchanges') | 551 raise error.Abort(b'phabdiff.addchange only takes phabchanges') |
552 self.changes[change.currentPath] = change | 552 self.changes[change.currentPath] = pycompat.byteskwargs( |
553 attr.asdict(change) | |
554 ) | |
553 | 555 |
554 | 556 |
555 def maketext(pchange, ctx, fname): | 557 def maketext(pchange, ctx, fname): |
556 """populate the phabchange for a text file""" | 558 """populate the phabchange for a text file""" |
557 repo = ctx.repo() | 559 repo = ctx.repo() |