##// END OF EJS Templates
phabricator: add the phabchange data structure...
Ian Moody -
r43454:99ee4afd default
parent child Browse files
Show More
@@ -481,6 +481,47 b' class phabhunk(dict):'
481 delLines = attr.ib(default=0) # camelcase-required
481 delLines = attr.ib(default=0) # camelcase-required
482
482
483
483
484 @attr.s
485 class phabchange(object):
486 """Represents a Differential change, owns Differential hunks and owned by a
487 Differential diff. Each one represents one file in a diff.
488 """
489
490 currentPath = attr.ib(default=None) # camelcase-required
491 oldPath = attr.ib(default=None) # camelcase-required
492 awayPaths = attr.ib(default=attr.Factory(list)) # camelcase-required
493 metadata = attr.ib(default=attr.Factory(dict))
494 oldProperties = attr.ib(default=attr.Factory(dict)) # camelcase-required
495 newProperties = attr.ib(default=attr.Factory(dict)) # camelcase-required
496 type = attr.ib(default=DiffChangeType.CHANGE)
497 fileType = attr.ib(default=DiffFileType.TEXT) # camelcase-required
498 commitHash = attr.ib(default=None) # camelcase-required
499 addLines = attr.ib(default=0) # camelcase-required
500 delLines = attr.ib(default=0) # camelcase-required
501 hunks = attr.ib(default=attr.Factory(list))
502
503 def copynewmetadatatoold(self):
504 for key in list(self.metadata.keys()):
505 newkey = key.replace(b'new:', b'old:')
506 self.metadata[newkey] = self.metadata[key]
507
508 def addoldmode(self, value):
509 self.oldProperties[b'unix:filemode'] = value
510
511 def addnewmode(self, value):
512 self.newProperties[b'unix:filemode'] = value
513
514 def addhunk(self, hunk):
515 if not isinstance(hunk, phabhunk):
516 raise error.Abort(b'phabchange.addhunk only takes phabhunks')
517 self.hunks.append(hunk)
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
520 # in email subjects for the [+++--] bit.
521 self.addLines += hunk.addLines
522 self.delLines += hunk.delLines
523
524
484 def creatediff(ctx):
525 def creatediff(ctx):
485 """create a Differential Diff"""
526 """create a Differential Diff"""
486 repo = ctx.repo()
527 repo = ctx.repo()
General Comments 0
You need to be logged in to leave comments. Login now