comparison hgext/phabricator.py @ 43185:75e7628b488f

phabricator: add the phabdiff data structure This holds all the data about a commit, and is passed to the differential.creatediff API. Differential Revision: https://phab.mercurial-scm.org/D7044
author Ian Moody <moz-ian@perix.co.uk>
date Sun, 06 Oct 2019 14:53:03 +0100
parents 99ee4afd352f
children f742fabad507
comparison
equal deleted inserted replaced
43184:99ee4afd352f 43185:75e7628b488f
518 # It's useful to include these stats since the Phab web UI shows them, 518 # It's useful to include these stats since the Phab web UI shows them,
519 # and uses them to estimate how large a change a Revision is. Also used 519 # and uses them to estimate how large a change a Revision is. Also used
520 # in email subjects for the [+++--] bit. 520 # in email subjects for the [+++--] bit.
521 self.addLines += hunk.addLines 521 self.addLines += hunk.addLines
522 self.delLines += hunk.delLines 522 self.delLines += hunk.delLines
523
524
525 @attr.s
526 class phabdiff(object):
527 """Represents a Differential diff, owns Differential changes. Corresponds
528 to a commit.
529 """
530
531 # Doesn't seem to be any reason to send this (output of uname -n)
532 sourceMachine = attr.ib(default=b'') # camelcase-required
533 sourcePath = attr.ib(default=b'/') # camelcase-required
534 sourceControlBaseRevision = attr.ib(default=b'0' * 40) # camelcase-required
535 sourceControlPath = attr.ib(default=b'/') # camelcase-required
536 sourceControlSystem = attr.ib(default=b'hg') # camelcase-required
537 branch = attr.ib(default=b'default')
538 bookmark = attr.ib(default=None)
539 creationMethod = attr.ib(default=b'phabsend') # camelcase-required
540 lintStatus = attr.ib(default=b'none') # camelcase-required
541 unitStatus = attr.ib(default=b'none') # camelcase-required
542 changes = attr.ib(default=attr.Factory(dict))
543 repositoryPHID = attr.ib(default=None) # camelcase-required
544
545 def addchange(self, change):
546 if not isinstance(change, phabchange):
547 raise error.Abort(b'phabdiff.addchange only takes phabchanges')
548 self.changes[change.currentPath] = change
523 549
524 550
525 def creatediff(ctx): 551 def creatediff(ctx):
526 """create a Differential Diff""" 552 """create a Differential Diff"""
527 repo = ctx.repo() 553 repo = ctx.repo()