Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/herald/HeraldCommitAdapter.php
| Show First 20 Lines • Show All 198 Lines • ▼ Show 20 Lines | public static function getEnormousByteLimit() { | ||||
| return 1024 * 1024 * 1024; // 1GB | return 1024 * 1024 * 1024; // 1GB | ||||
| } | } | ||||
| public static function getEnormousTimeLimit() { | public static function getEnormousTimeLimit() { | ||||
| return 60 * 15; // 15 Minutes | return 60 * 15; // 15 Minutes | ||||
| } | } | ||||
| private function loadCommitDiff() { | private function loadCommitDiff() { | ||||
| $viewer = PhabricatorUser::getOmnipotentUser(); | |||||
| $byte_limit = self::getEnormousByteLimit(); | $byte_limit = self::getEnormousByteLimit(); | ||||
| $time_limit = self::getEnormousTimeLimit(); | |||||
| $raw = $this->callConduit( | $diff_info = $this->callConduit( | ||||
| 'diffusion.rawdiffquery', | 'diffusion.rawdiffquery', | ||||
| array( | array( | ||||
| 'commit' => $this->commit->getCommitIdentifier(), | 'commit' => $this->commit->getCommitIdentifier(), | ||||
| 'timeout' => self::getEnormousTimeLimit(), | 'timeout' => $time_limit, | ||||
| 'byteLimit' => $byte_limit, | 'byteLimit' => $byte_limit, | ||||
| 'linesOfContext' => 0, | 'linesOfContext' => 0, | ||||
| )); | )); | ||||
| if (strlen($raw) >= $byte_limit) { | if ($diff_info['tooHuge']) { | ||||
| throw new Exception( | throw new Exception( | ||||
| pht( | pht( | ||||
| 'The raw text of this change is enormous (larger than %d bytes). '. | 'The raw text of this change is enormous (larger than %s byte(s)). '. | ||||
| 'Herald can not process it.', | 'Herald can not process it.', | ||||
| $byte_limit)); | new PhutilNumber($byte_limit))); | ||||
| } | } | ||||
| if ($diff_info['tooSlow']) { | |||||
| throw new Exception( | |||||
| pht( | |||||
| 'The raw text of this change took too long to process (longer '. | |||||
| 'than %s second(s)). Herald can not process it.', | |||||
| new PhutilNumber($time_limit))); | |||||
| } | |||||
| $file_phid = $diff_info['filePHID']; | |||||
| $diff_file = id(new PhabricatorFileQuery()) | |||||
| ->setViewer($viewer) | |||||
| ->withPHIDs(array($file_phid)) | |||||
| ->executeOne(); | |||||
| if (!$diff_file) { | |||||
| throw new Exception( | |||||
| pht( | |||||
| 'Failed to load diff ("%s") for this change.', | |||||
| $file_phid)); | |||||
| } | |||||
| $raw = $diff_file->loadFileData(); | |||||
| $parser = new ArcanistDiffParser(); | $parser = new ArcanistDiffParser(); | ||||
| $changes = $parser->parseDiff($raw); | $changes = $parser->parseDiff($raw); | ||||
| $diff = DifferentialDiff::newEphemeralFromRawChanges( | $diff = DifferentialDiff::newEphemeralFromRawChanges( | ||||
| $changes); | $changes); | ||||
| return $diff; | return $diff; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 103 Lines • Show Last 20 Lines | |||||