3 final class DiffusionPathChange
extends Phobject
{
6 private $commitIdentifier;
13 private $targetCommitIdentifier;
14 private $awayPaths = array();
16 public function setPath($path) {
21 public function getPath() {
25 public function setChangeType($change_type) {
26 $this->changeType
= $change_type;
30 public function getChangeType() {
31 return $this->changeType
;
34 public function setFileType($file_type) {
35 $this->fileType
= $file_type;
39 public function getFileType() {
40 return $this->fileType
;
43 public function setTargetPath($target_path) {
44 $this->targetPath
= $target_path;
48 public function getTargetPath() {
49 return $this->targetPath
;
52 public function setAwayPaths(array $away_paths) {
53 $this->awayPaths
= $away_paths;
57 public function getAwayPaths() {
58 return $this->awayPaths
;
61 public function setCommitIdentifier($commit) {
62 $this->commitIdentifier
= $commit;
66 public function getCommitIdentifier() {
67 return $this->commitIdentifier
;
70 public function setTargetCommitIdentifier($target_commit_identifier) {
71 $this->targetCommitIdentifier
= $target_commit_identifier;
75 public function getTargetCommitIdentifier() {
76 return $this->targetCommitIdentifier
;
79 public function setCommit($commit) {
80 $this->commit
= $commit;
84 public function getCommit() {
88 public function setCommitData($commit_data) {
89 $this->commitData
= $commit_data;
93 public function getCommitData() {
94 return $this->commitData
;
98 public function getEpoch() {
99 if ($this->getCommit()) {
100 return $this->getCommit()->getEpoch();
105 public function getAuthorName() {
106 if ($this->getCommitData()) {
107 return $this->getCommitData()->getAuthorString();
112 public function getSummary() {
113 if (!$this->getCommitData()) {
116 return $this->getCommitData()->getSummary();
119 public static function convertToArcanistChanges(array $changes) {
120 assert_instances_of($changes, __CLASS__
);
123 foreach ($changes as $path) {
124 $change = new ArcanistDiffChange();
125 $change->setCurrentPath($path->getPath());
126 $direct[] = $path->getPath();
127 $change->setType($path->getChangeType());
128 $file_type = $path->getFileType();
129 if ($file_type == DifferentialChangeType
::FILE_NORMAL
) {
130 $file_type = DifferentialChangeType
::FILE_TEXT
;
132 $change->setFileType($file_type);
133 $change->setOldPath($path->getTargetPath());
134 foreach ($path->getAwayPaths() as $away_path) {
135 $change->addAwayPath($away_path);
137 $result[$path->getPath()] = $change;
140 return array_select_keys($result, $direct);
143 public static function convertToDifferentialChangesets(
144 PhabricatorUser
$user,
146 assert_instances_of($changes, __CLASS__
);
147 $arcanist_changes = self
::convertToArcanistChanges($changes);
148 $diff = DifferentialDiff
::newEphemeralFromRawChanges(
150 return $diff->getChangesets();
153 public function toDictionary() {
154 $commit = $this->getCommit();
156 $commit_dict = $commit->toDictionary();
158 $commit_dict = array();
160 $commit_data = $this->getCommitData();
162 $commit_data_dict = $commit_data->toDictionary();
164 $commit_data_dict = array();
167 'path' => $this->getPath(),
168 'commitIdentifier' => $this->getCommitIdentifier(),
169 'commit' => $commit_dict,
170 'commitData' => $commit_data_dict,
171 'fileType' => $this->getFileType(),
172 'changeType' => $this->getChangeType(),
173 'targetPath' => $this->getTargetPath(),
174 'targetCommitIdentifier' => $this->getTargetCommitIdentifier(),
175 'awayPaths' => $this->getAwayPaths(),
179 public static function newFromConduit(array $dicts) {
181 foreach ($dicts as $dict) {
182 $commit = PhabricatorRepositoryCommit
::newFromDictionary($dict['commit']);
184 PhabricatorRepositoryCommitData
::newFromDictionary(
185 $dict['commitData']);
186 $results[] = id(new DiffusionPathChange())
187 ->setPath($dict['path'])
188 ->setCommitIdentifier($dict['commitIdentifier'])
190 ->setCommitData($commit_data)
191 ->setFileType($dict['fileType'])
192 ->setChangeType($dict['changeType'])
193 ->setTargetPath($dict['targetPath'])
194 ->setTargetCommitIdentifier($dict['targetCommitIdentifier'])
195 ->setAwayPaths($dict['awayPaths']);