Differential D16460 Diff 39599 src/applications/differential/engine/DifferentialDiffExtractionEngine.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/engine/DifferentialDiffExtractionEngine.php
| Show All 30 Lines | public function newDiffFromCommit(PhabricatorRepositoryCommit $commit) { | ||||
| $monogram = $commit->getMonogram(); | $monogram = $commit->getMonogram(); | ||||
| $drequest = DiffusionRequest::newFromDictionary( | $drequest = DiffusionRequest::newFromDictionary( | ||||
| array( | array( | ||||
| 'user' => $viewer, | 'user' => $viewer, | ||||
| 'repository' => $repository, | 'repository' => $repository, | ||||
| )); | )); | ||||
| $raw_diff = DiffusionQuery::callConduitWithDiffusionRequest( | $diff_info = DiffusionQuery::callConduitWithDiffusionRequest( | ||||
| $viewer, | $viewer, | ||||
| $drequest, | $drequest, | ||||
| 'diffusion.rawdiffquery', | 'diffusion.rawdiffquery', | ||||
| array( | array( | ||||
| 'commit' => $identifier, | 'commit' => $identifier, | ||||
| )); | )); | ||||
| $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 file ("%s") returned by "%s".', | |||||
| $file_phid, | |||||
| 'diffusion.rawdiffquery')); | |||||
| } | |||||
| $raw_diff = $diff_file->loadFileData(); | |||||
| // TODO: Support adds, deletes and moves under SVN. | // TODO: Support adds, deletes and moves under SVN. | ||||
| if (strlen($raw_diff)) { | if (strlen($raw_diff)) { | ||||
| $changes = id(new ArcanistDiffParser())->parseDiff($raw_diff); | $changes = id(new ArcanistDiffParser())->parseDiff($raw_diff); | ||||
| } else { | } else { | ||||
| // This is an empty diff, maybe made with `git commit --allow-empty`. | // This is an empty diff, maybe made with `git commit --allow-empty`. | ||||
| // NOTE: These diffs have the same tree hash as their ancestors, so | // NOTE: These diffs have the same tree hash as their ancestors, so | ||||
| // they may attach to revisions in an unexpected way. Just let this | // they may attach to revisions in an unexpected way. Just let this | ||||
| // happen for now, although it might make sense to special case it | // happen for now, although it might make sense to special case it | ||||
| ▲ Show 20 Lines • Show All 222 Lines • Show Last 20 Lines | |||||