Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/storage/DifferentialChangeset.php
| Show All 16 Lines | final class DifferentialChangeset | ||||
| protected $newProperties; | protected $newProperties; | ||||
| protected $addLines; | protected $addLines; | ||||
| protected $delLines; | protected $delLines; | ||||
| private $unsavedHunks = array(); | private $unsavedHunks = array(); | ||||
| private $hunks = self::ATTACHABLE; | private $hunks = self::ATTACHABLE; | ||||
| private $diff = self::ATTACHABLE; | private $diff = self::ATTACHABLE; | ||||
| private $authorityPackages; | |||||
| private $changesetPackages; | |||||
| const TABLE_CACHE = 'differential_changeset_parse_cache'; | const TABLE_CACHE = 'differential_changeset_parse_cache'; | ||||
| const METADATA_TRUSTED_ATTRIBUTES = 'attributes.trusted'; | const METADATA_TRUSTED_ATTRIBUTES = 'attributes.trusted'; | ||||
| const METADATA_UNTRUSTED_ATTRIBUTES = 'attributes.untrusted'; | const METADATA_UNTRUSTED_ATTRIBUTES = 'attributes.untrusted'; | ||||
| const METADATA_EFFECT_HASH = 'hash.effect'; | const METADATA_EFFECT_HASH = 'hash.effect'; | ||||
| const ATTRIBUTE_GENERATED = 'generated'; | const ATTRIBUTE_GENERATED = 'generated'; | ||||
| ▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | public function addUnsavedHunk(DifferentialHunk $hunk) { | ||||
| if ($this->hunks === self::ATTACHABLE) { | if ($this->hunks === self::ATTACHABLE) { | ||||
| $this->hunks = array(); | $this->hunks = array(); | ||||
| } | } | ||||
| $this->hunks[] = $hunk; | $this->hunks[] = $hunk; | ||||
| $this->unsavedHunks[] = $hunk; | $this->unsavedHunks[] = $hunk; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function setAuthorityPackages(array $authority_packages) { | |||||
| $this->authorityPackages = mpull($authority_packages, null, 'getPHID'); | |||||
| return $this; | |||||
| } | |||||
| public function getAuthorityPackages() { | |||||
| return $this->authorityPackages; | |||||
| } | |||||
| public function setChangesetPackages($changeset_packages) { | |||||
| $this->changesetPackages = mpull($changeset_packages, null, 'getPHID'); | |||||
| return $this; | |||||
| } | |||||
| public function getChangesetPackages() { | |||||
| return $this->changesetPackages; | |||||
| } | |||||
| public function save() { | public function save() { | ||||
| $this->openTransaction(); | $this->openTransaction(); | ||||
| $ret = parent::save(); | $ret = parent::save(); | ||||
| foreach ($this->unsavedHunks as $hunk) { | foreach ($this->unsavedHunks as $hunk) { | ||||
| $hunk->setChangesetID($this->getID()); | $hunk->setChangesetID($this->getID()); | ||||
| $hunk->save(); | $hunk->save(); | ||||
| } | } | ||||
| $this->saveTransaction(); | $this->saveTransaction(); | ||||
| ▲ Show 20 Lines • Show All 140 Lines • ▼ Show 20 Lines | final class DifferentialChangeset | ||||
| public function newFileTreeIcon() { | public function newFileTreeIcon() { | ||||
| $icon = $this->getPathIconIcon(); | $icon = $this->getPathIconIcon(); | ||||
| $color = $this->getPathIconColor(); | $color = $this->getPathIconColor(); | ||||
| return id(new PHUIIconView()) | return id(new PHUIIconView()) | ||||
| ->setIcon("{$icon} {$color}"); | ->setIcon("{$icon} {$color}"); | ||||
| } | } | ||||
| public function getIsOwnedChangeset() { | |||||
| $authority_packages = $this->getAuthorityPackages(); | |||||
| $changeset_packages = $this->getChangesetPackages(); | |||||
| if (!$authority_packages || !$changeset_packages) { | |||||
| return false; | |||||
| } | |||||
| return (bool)array_intersect_key($authority_packages, $changeset_packages); | |||||
| } | |||||
| public function getIsLowImportanceChangeset() { | |||||
| $change_type = $this->getChangeType(); | |||||
| $change_map = array( | |||||
| DifferentialChangeType::TYPE_DELETE => true, | |||||
| DifferentialChangeType::TYPE_MOVE_AWAY => true, | |||||
| DifferentialChangeType::TYPE_MULTICOPY => true, | |||||
| ); | |||||
| if (isset($change_map[$change_type])) { | |||||
| return $change_map[$change_type]; | |||||
| } | |||||
| if ($this->isGeneratedChangeset()) { | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| } | |||||
| public function getPathIconIcon() { | public function getPathIconIcon() { | ||||
| return idx($this->getPathIconDetails(), 'icon'); | return idx($this->getPathIconDetails(), 'icon'); | ||||
| } | } | ||||
| public function getPathIconColor() { | public function getPathIconColor() { | ||||
| return idx($this->getPathIconDetails(), 'color'); | return idx($this->getPathIconDetails(), 'color'); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 173 Lines • Show Last 20 Lines | |||||