Changeset View
Changeset View
Standalone View
Standalone View
src/parser/diff/ArcanistDiffChange.php
| Show First 20 Lines • Show All 265 Lines • ▼ Show 20 Lines | public function renderTextSummary() { | ||||
| $char = ArcanistDiffChangeType::getSummaryCharacterForChangeType($type); | $char = ArcanistDiffChangeType::getSummaryCharacterForChangeType($type); | ||||
| $attr = ArcanistDiffChangeType::getShortNameForFileType($file); | $attr = ArcanistDiffChangeType::getShortNameForFileType($file); | ||||
| if ($attr) { | if ($attr) { | ||||
| $attr = '('.$attr.')'; | $attr = '('.$attr.')'; | ||||
| } | } | ||||
| $summary = array(); | $summary = array(); | ||||
| $summary[] = sprintf( | $summary[] = sprintf( | ||||
| "%s %5.5s %s", | '%s %5.5s %s', | ||||
| $char, | $char, | ||||
| $attr, | $attr, | ||||
| $this->getCurrentPath()); | $this->getCurrentPath()); | ||||
| if (ArcanistDiffChangeType::isOldLocationChangeType($type)) { | if (ArcanistDiffChangeType::isOldLocationChangeType($type)) { | ||||
| foreach ($this->getAwayPaths() as $path) { | foreach ($this->getAwayPaths() as $path) { | ||||
| $summary[] = ' to: '.$path; | $summary[] = ' to: '.$path; | ||||
| } | } | ||||
| } | } | ||||
| if (ArcanistDiffChangeType::isNewLocationChangeType($type)) { | if (ArcanistDiffChangeType::isNewLocationChangeType($type)) { | ||||
| $summary[] = ' from: '.$this->getOldPath(); | $summary[] = ' from: '.$this->getOldPath(); | ||||
| } | } | ||||
| return implode("\n", $summary); | return implode("\n", $summary); | ||||
| } | } | ||||
| public function getSymlinkTarget() { | public function getSymlinkTarget() { | ||||
| if ($this->getFileType() != ArcanistDiffChangeType::FILE_SYMLINK) { | if ($this->getFileType() != ArcanistDiffChangeType::FILE_SYMLINK) { | ||||
| throw new Exception("Not a symlink!"); | throw new Exception('Not a symlink!'); | ||||
| } | } | ||||
| $hunks = $this->getHunks(); | $hunks = $this->getHunks(); | ||||
| $hunk = reset($hunks); | $hunk = reset($hunks); | ||||
| $corpus = $hunk->getCorpus(); | $corpus = $hunk->getCorpus(); | ||||
| $match = null; | $match = null; | ||||
| if (!preg_match('/^\+(?:link )?(.*)$/m', $corpus, $match)) { | if (!preg_match('/^\+(?:link )?(.*)$/m', $corpus, $match)) { | ||||
| throw new Exception("Failed to extract link target!"); | throw new Exception('Failed to extract link target!'); | ||||
| } | } | ||||
| return trim($match[1]); | return trim($match[1]); | ||||
| } | } | ||||
| public function setNeedsSyntheticGitHunks($needs_synthetic_git_hunks) { | public function setNeedsSyntheticGitHunks($needs_synthetic_git_hunks) { | ||||
| $this->needsSyntheticGitHunks = $needs_synthetic_git_hunks; | $this->needsSyntheticGitHunks = $needs_synthetic_git_hunks; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getNeedsSyntheticGitHunks() { | public function getNeedsSyntheticGitHunks() { | ||||
| return $this->needsSyntheticGitHunks; | return $this->needsSyntheticGitHunks; | ||||
| } | } | ||||
| } | } | ||||